Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created June 2, 2012 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2856303 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2856303 to your computer and use it in GitHub Desktop.
Using the Symfony 2 HTTP Foundation component - http://www.symfonycentral.com
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/* Using the HTTP Foundation class */
$request = Request::createFromGlobals();
$input = $request->get('name', 'World');
$response = new Response('Hello ' . $input);
$response->send();
/* ... instead of this: */
$input = !empty($_GET['name']) ? $_GET['name'] : 'World';
echo 'Hello ' . $input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment