- Create a variable named ‘items’ with a value of 100.9
- Create an associative array with indexs “name”, “age”, “height” and values of “jose”, 28, “128cm” respectively, then assign it to a variable named ‘person’.
- Using the variable in #2, print the value of index ‘name’.
- Write an If statement that checks if the variable in #1 is greater than 50 then print “You have enough balance.”
- Using Foreach, loop each items in #2 and print their values.
- Create a class Ball with public property color and owner with public function named bounce.
- Create a new variable ‘spalding’ that reference to the class of #6.
- Use the variable in #7 and assign a value of “red” to property color
- Call the function bounce in variable #7
- Use the variable in #7 and assign a value of “John” to property owner.
<?php
// #1
$items = 100.9
// #2
$person = array( "name" => "jose", "age" => 28, "height" => "128cm" );
// #3
echo $person[ "name" ];
// #4
if( $items > 50 ) {
echo "You have enough balance.";
}
// #5
foreach( $person as $p ) {
echo $p[ "name" ];
echo $p[ "age" ];
echo $p[ "height" ];
}
// #6
class Ball {
public color;
public owner;
public function bounce() {
}
}
// #7
$spalding = new Ball();
// #8
$spalding->color = "red";
// #9
$spalding->bounce();
// #10
$spalding->owner = "John";
?>