Lab 1 Exercise 2. Write a script that declares and assigns five different variables. Populate them with values of different data types and use the gettype ( ) function to print each type to the browser.
**************************************************************
CODES:
<?php
function printBR($txt) {
echo $txt."<br />";
}
$myString = "Hi, welcome to my page!";
$myBoolean = true;
$myDouble = 4.234;
$myInteger = 3;
$myNull;
printBR("My string is: ".$myString.", and it's type is: ".gettype($myString));
printBR("My Boolean is: ".$myBoolean.", and it's type is: ".gettype($myBoolean));
printBR("My double is: ".$myDouble.", and it's type is: ".gettype($myDouble));
printBR("My integer is: ".$myInteger.", and it's type is: ".gettype($myInteger));
printBR("My null is: ".$nyNull.", and it's type is: ".gettype($myNull));
?>
**************************************************************
ANSWER:
My string is: Hi, welcome to my page!, and it's type is: string
My Boolean is: 1, and it's type is: boolean
My double is: 4.234, and it's type is: double
My integer is: 3, and it's type is: integer
My null is: , and it's type is: NULL
**************************************************************
BACKGROUND: see text, Standard Data Types, p. 91
Reference Examples: 135-printbr
Why didn't this work?
$myColorArray = array('blue', 'green', 'red', 'yellow');
echo $myColorArray."<br />";