
<?php

	//1 - What is the final value of $num?

	$num = 10;
	function multiply(){
		$num = $num * 10;
	}
	multiply();
	echo $num;
?>



<?php

	//2 - What is the final value of $a?

	$a .= "a";
	$a .= "b";
	$a .= "c";
?>



<?php

	//3 - Which of these is of type string?
	
	$a = true;
	$b = "true";
	$c[] = "true";

?>


<?php

	//4 - What is the value of $d?

	$a = "0";
	$b = "0";

	if ( ($a != "1" && $b == "1") || ($a != "0") || ($b != "1") ){
		$d = "0";
	}else{
		$d = "1";
	}
	
?>

<?php

	//5 - Can you explain the code below?
	
	$arr = array (
		"zero" 	=> 0,
		"one" 	=> 1,
		"two" 	=> 2
	}

	if ( count($arr) != 0 ) {
	
		print "<ul>";

		foreach ( $arr as $key => $value ) {
			print "<li>" . $key . " is " . $value . "</li>";
		}

		print "</ul>";
		
	}//EOI arr size is 0
?>


<?php

	//6 - Can you explain this code?
	
	class person {
	
		var $name;
		var $email;
		
		//Getters
		function get_name() { return $this->name; }
		function get_email() { return $this->email;	}
		
		//Setters
		function set_name( $name ) { $this->name = $name; }
		
		function set_email( $email ) {

			if ( !eregi("^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])*$", $email ) ) {
				return false;
			} else { 
				$this->email = $email;
				return true;
			}
		
		}//EOM set_email
	
	}//EOC person
	
?>