📎

PHP Syntax

Hypertext Preprocessor PHP

Server-side scripting language.

Variable names start with $ .

The . operator concatenates strings.

Important global associative arrays (= dictionaries):

$_GET URL query string parameters

$_POST request body parameters

$_SESSION PHP session (preserved across multiple requests) parameters

Example: (Vulnerable to XSS, do not use)

<HTML>
<BODY>
<P><?php echo "Hello " . $_GET["name"]; ?></P>
</BODY>
</HTML>
GET /index.php?name=Mauro HTTP/2
Host: example.com

Writing Host: example.com is necessary because the same IP address can host multiple websites.

<HTML>
<BODY>
<P>Hello Mauro</P>
</BODY>
</HTML>