"; //repeat "happy to program!" three times by echoing a call to str_repeat( ) echo str_repeat("happy to program!", 3) . "
"; //convert to upper case "i like php string functions" by using the appropriate //function call. Store the result of the call into variable $s1. Echo $s1. $s1 = strtoupper("i like php string functions"); echo "$s1
"; //store in variable $s2 the return value from calling str_shuffle( ) //with argument "making mistakes teaches you php". $s2 = str_shuffle("making mistakes teaches you php"); //shuffle the same string value again and store it in $s3. $s3 = str_shuffle("making mistakes teaches you php"); //and shuffle once more time and store result in $s4. $s4 = str_shuffle("making mistakes teaches you php"); //echo $s2, $s3, and $s4, on separate lines. echo "$s2
$s3
$s4
"; //echo again $s2, $s3, and $s4, but this time capitalize all the words. //hint: use ucwords( ) call. echo ucwords($s2) . "
" . ucwords($s3) . "
" . ucwords($s4) . "
"; } /* * Creates and prints out an array. */ function littleBitTasteOfArrays($elem1, $elem2, $elem3 ) { //make an array from the three parameters and store result in $myFirstArray. //hint: use array( ) call to make the array. $myFirstArray = array($elem1, $elem2, $elem3); //echo variable $myFirstArray. echo "My first array is:
$myFirstArray
"; //use print_r( ) with argument $myFirsArray to print out the variable array. print_r($myFirstArray); } /* * Sums up the given parameters. * @param $a number * @param $b number * @param $c number * @return number has the sum value of the given paramaters. */ function addThree($a, $b, $c) { //store the sum of the three parameters into variable $sum $sum = $a + $b + $c; //return the value of the sum return $sum; } /* * Assigns expressions to variables and prints out those variables. */ function bunchOfExpressions( ) { echo "
Executing bunchOfExpressions( )...
"; //display message $e1 = 1; //replace 1 above with complicated arithmetic expression. $e1 = 2 + 3 * 7 - 10; //expression evaluates to 13 echo "e1 = $e1
"; //outputs 13 $e2 = true; //replace true above with complicated logical expression. $e2 = true && (false || true); //expression evaluates to true echo "e2 = $e2
"; //outputs 1 $e3 = true; //replace true above with a complicated expresison that has a combination of //arithmetic, logical, and comparison operators - at least 10 of them. //you can use parantheses. $e3 = (3 > 1) || !(2 * 7 + 10 == 0) && (-3 + 2 / 1); //expression evaluates to true echo "e3 = $e3
"; //outputs 1 //call addThree( ) function with the following arguments: $e1, 5, and $e1 * 2. echo "addThree($e1, 5, " . ($e1 * 2) . ") is: " . addThree($e1, 5, $e1 * 2); //outputs 44 echo "
Done!

"; } /********* EXTRA STUFF: ABSOLUTELY OPTIONAL *****************************/ /************************************************************************/ /* * Outputs HTML text that contains the string value provided by the parameter. * Uses calls to the printf( ) function, which is part of the PHP library. * @param $s string has a concatenation expression in textual form. */ function prompt($s) { printf("

You write: echo %s", $s); printf("
Browser shows: "); } /* * Demonstrates how concatenation operator works in expresions that include * other operators, such as arithmetic + and -. */ function echoStuff( ) { prompt("1.234 . \" is 1.234\""); echo 1.234 . " is 1.234"; prompt("1 + 3 . \" is 1 + 3\""); echo 1 + 3 . " is 1 + 3"; prompt("\"1 + 3 is \" . 1 + 3"); echo "1 + 3 is " . 1 + 3; prompt("3 + \"oh my goodness\""); echo 3 + "oh my goodness"; prompt("\"Hmmm \" . 5 - 2 . \" is 5 - 2\""); echo "Hmmm " . 5-2 . " is 5 - 2"; prompt("+2 \" is +2\""); echo +2 . " is +2"; prompt("\"+2 is \" . +2"); echo "+2 is " . +2; $a = 1; $b = 2; prompt("\"\$a - \$b = \" . $a - $b"); echo "$a - $b = " . $a - $b; } ?>