PHP Flashcards
What is PHP?
Server side scripting language; PHP code is executed on a server and HTML is delivered to a browser
What database server is often used with PHP, and why?
MySQL, because it’s free and cross-platform
Write the PHP code for a page that would say hello world, and include both kinds of comments.
echo "hello world"; //comment /* comment */
Declare variables for first name and last name, then concatenate and output.
$fn = “joe”;
$ln = “pasini”;
echo $fn . “ “ . $ln;
Instantiate a numeric array with four fruits.
$fruits=array(“Apples”,”Bananas”,”Pineapples”,”Strawberries”);
Instantiate an associative array with three names/ages
$ages=array(“Peter”=>32,”Paul”=>30,”Mary”=>29);
Instantiate a mutidimensional array (arrays of arrays!)
$families = array ( "Griffin"=>array ( "Peter", "Lois", "Megan" ), "Quagmire"=>array ( "Glenn" ), "Brown"=>array ( "Cleveland", "Loretta", "Junior" ) );
The three logical operators in PHP
&&
||
!
Write a three-condition conditional statement
if (a==b) echo "a = b"; elseif (a>b) echo "a > b"; else echo "a<b></b>
Write a switch statement. What is important to add to each piece? What happens if it’s left out?
switch ($day) { case "Friday": echo "Friday"; break;
case “Monday”:
echo “Monday”;
break;
default:
echo “no day”;
}
Write each loop
for ($i=1, $i
What does PHP stand for?
PHP Hypertext Preprocessor (a recursive backronym); originally Personal Home Page.