A GET Request

One way to pass information between PHP scripts is via the URL we use to access the script. The following script does just that. It looks for a query string at the end of the URL used to access the page and uses the information when producing the HTML content.

<title>PHP Test</title>
$thename= $_GET['name'];
echo "<h1>Hello ".$thename."</h1>";

Copy this code and save the page with the name get.php. If you navigate to this file in the browser as you did before, you should see a page that just says 'Hello'. That is because this script is looking for a query string at the end of the URL to know what it is expected to include on the page. Try the following,

Something else to notice about this script is the way that the variable is used. All variables in PHP must being with a $. Notice that there is no declaration - you don't need to do this in PHP. PHP, like Javascript is untyped. That means that data types are picked up by the interpreter based on the context in which they are used.

The full stop is the concatenation operator (for adding strings together).