In class example

Return to Cpsc110/Notes/Starting PHP

   Hello World   This was printed by PHP."; $result = "20"/5; $result2 = 20/5; echo "\$result is $result"; echo '\$result2 is $result2'; echo "\$result2 is $result2";

// Define a function function birthday { global $age; $age = 1; // Set local variable age to 1 $age = $age + 1; echo "In birthday age is $age "; }	birthday; $age = 30;  // Set age to 30 birthday; // Call the function echo "Outside age is $age ";  // This will print 30

$name1 = "Bill"; $name2 = "BIll"; $result = strcasecmp($name1, $name2); // Compare but ignore case, returns 0 echo "Comparing $name1 and $name2, ingoring case and result is $result"; if (!$result) { echo "They match, ignoring case";  // This will print in this case, because != 0 }

$result = strcmp($name1, $name2); // Compare but include case, returns non-zero echo "Comparing $name1 and $name2, including case and result is $result"; if ($result) { echo "They don't match, including case";  // This will also print in this case b/c $result is non-zero }

?> </BODY> </HTML>

Return to Cpsc110/Notes/Starting PHP