PHP Flashcards

1
Q

What is PHP?

A

Server side scripting language; PHP code is executed on a server and HTML is delivered to a browser

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What database server is often used with PHP, and why?

A

MySQL, because it’s free and cross-platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write the PHP code for a page that would say hello world, and include both kinds of comments.

A
echo "hello world";
//comment
/* comment
*/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Declare variables for first name and last name, then concatenate and output.

A

$fn = “joe”;
$ln = “pasini”;
echo $fn . “ “ . $ln;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Instantiate a numeric array with four fruits.

A

$fruits=array(“Apples”,”Bananas”,”Pineapples”,”Strawberries”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Instantiate an associative array with three names/ages

A

$ages=array(“Peter”=>32,”Paul”=>30,”Mary”=>29);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Instantiate a mutidimensional array (arrays of arrays!)

A
$families = array
    (
    "Griffin"=>array
    (
    "Peter",
    "Lois",
    "Megan"
    ),
    "Quagmire"=>array
    (
    "Glenn"
    ),
    "Brown"=>array
    (
    "Cleveland",
    "Loretta",
    "Junior"
    )
    );
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The three logical operators in PHP

A

&&
||
!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write a three-condition conditional statement

A
if (a==b)
   echo "a = b";
elseif (a>b)
   echo "a > b";
else
   echo "a<b></b>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write a switch statement. What is important to add to each piece? What happens if it’s left out?

A
switch ($day)
{
  case "Friday":
      echo "Friday";
      break;

case “Monday”:
echo “Monday”;
break;

default:
echo “no day”;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write each loop

A

for ($i=1, $i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does PHP stand for?

A

PHP Hypertext Preprocessor (a recursive backronym); originally Personal Home Page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly