<?php
$greeting = "Hello";
$place = "World";
$num = 3;
$data = array(
0 => "zero",
1 => "one"
);
echo "<pre>";
echo $greeting;
echo "
";
echo '$greeting' . "$place";
echo "
";
echo $num * 8;
echo "
";
echo "Greeting
World";
echo "
";
echo $data['$num'].'is a
number';
echo "
";
echo "It's" . "$data[1]" . "small" . "$place";
echo "
";
echo $data;
echo "
";
echo substr($hello . " and good luck! ", 3, 15);
echo "
";
echo "<pre>";
?>
Here is PHP code that I received for testing purposes. I copied the code word for word, but for some reason I get the following errors:
Notice: Undefined index: $num in C:\xampp\htdocs\test.php on line 18
Notice: Array to string conversion in C:\xampp\htdocs\test.php on line 22
Notice: Undefined variable: hello in C:\xampp\htdocs\test.php on line 24
This was a question given on a midterm where I was supposed to interpret the output. It is possible that these errors were made on purpose, but I don't understand why. Could someone please explain why these errors are taking place?