Explorar el Código

GET paramters

master
Ruben De Baets hace 2 años
padre
commit
b61829698d
Se han modificado 2 ficheros con 52 adiciones y 4 borrados
  1. 47
    0
      .vscode/launch.json
  2. 5
    4
      public/index.php

+ 47
- 0
.vscode/launch.json Ver fichero

@@ -0,0 +1,47 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": { "/src": "${workspaceRoot}" }
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": ["-dxdebug.start_with_request=yes"],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}

+ 5
- 4
public/index.php Ver fichero

@@ -43,7 +43,7 @@ $app->get('/tweede', function (Request $request, Response $response, $args) {
$response->getBody()->write('<li><a href="/tweede/driekwart">tweede driekwart</a></li>');
$response->getBody()->write("</ul>");
$response->getBody()->write("<hr/>");
$response->getBody()->write('<form action="" method="POST');
$response->getBody()->write('<form action="/postdata" method="GET">');
$response->getBody()->write('<input type="text" name="naam"/>');
$response->getBody()->write('<br/>');
$response->getBody()->write('<input type="text" name="leeftijd"/>');
@@ -64,12 +64,13 @@ $app->get('/tweede/driekwart', function (Request $request, Response $response, $
return $response;
});

$app->post('/postdata', function (Request $request, Response $response, $args) {
$app->get('/postdata', function (Request $request, Response $response, $args) {

$a = $request->getParsedBody();
//$a = $request->getParsedBody();
$a = $request->getQueryParams();
$b = $request->getUploadedFiles();
$c = $request->getHeaders();
$response->getBody()->write("Onze naam is : " . $a['naam'] . " en we zijn " . $a['leeftijd'] . " jaar oud.");
$response->getBody()->write("Mijn naam is : " . $a['naam'] . " en ik ben " . $a['leeftijd'] . " jaar oud.");
return $response;
});


Cargando…
Cancelar
Guardar