Module 1 Notes

  1. PHP Manual

PHP Manual

Simple prints

php echo $_SERVER['HTTP_USER_AGENT'];

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

Other Reserved Variables

Simple if block

if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
    echo 'You are using Internet Explorer.<br />';
} else { echo 'You are not using Internet Explorer.<br />'; }

You are not using Internet Explorer.

Simple form

Variables

$a_bool = TRUE; // a boolean
$a_str = "foo"; // a string
$a_str2 = 'foo'; // a string
$an_int = 12; // an integer
$an_arr = array('1', 2, "$a_bool"); // an indexed array
$a_map = ["number" => '1',"integer" => 2, "String" => "$a_bool"]; // an associative array
$restructured_array = array_values($a_map); // a restructured array
$nested_array = [$a_map, $an_arr]; // a nested array

echo gettype($a_bool); // prints out: boolean
echo var_dump($a_str); // prints out: string(3) "foo"
echo gettype($an_arr); // prints out: array
echo var_dump($an_arr); // prints out: array(4) { [0]=> string(1) "1" [1]=> int(2) [2]=> string(1) "1" [3]=> string(11) "Hello World" }
echo var_dump($a_map); // prints out: array(4) { ["number"]=> string(1) "1" ["integer"]=> int(2) ["boolean"]=> string(1) "1" ["string"]=> string(11) "Hello World" }
echo var_dump($restructured_array); // prints out: array(4) { [0]=> string(1) "1" [1]=> int(2) [2]=> string(1) "1" [3]=> string(11) "Hello World" }
echo var_dump($nested_array); // prints out: array(2) { [0]=> array(4) { ["number"]=> string(1) "1" ["integer"]=> int(2) ["boolean"]=> string(1) "1" ["string"]=> string(11) "Hello World" } [1]=> array(4) { [0]=> string(1) "1" [1]=> int(2) [2]=> string(1) "1" [3]=> string(11) "Hello World" } }