Intro to PHP Flashcards
PHP: ______.
“PHP: Hypertext Preprocessor,” is a server language. This means that it executes code on the server then sends the results to the browser primarily as html content.
PHP manages __________ content, communicates with _____________, tracks user sessions, sends _______, read/write ________, implements __________, and ________ __________.
PHP manages dynamic content, communicates with databases, tracks user sessions, sends email, read/writes files, implements security, and processes forms.
A PHP block must begin with ______ and end with ______ .
a PHP block must begin with .
_______ PHP blocks can be used inside of one file.
Multiple PHP blocks can be used inside of one file.
Code (PHP) to output to page
echo(); //output to page
Code (PHP) that shows information about the server’s PHP installation
phpinfo(); //shows information about the server’s PHP installation
Code (PHP) to view all errors warnings and notices
error_reporting(E_ALL);
//view all errors warnings and notices
Different servers have different ________. If something doesn’t work, it might be a server ______ issue.
Different servers have different configurations. If something doesn’t work, it might be a server configuration issue.
PHP and HTML code _____ be used on the same page.
A simple way to use this technique effectively is to remember that _____ goes inside of PHP blocks and HTML _____t.
PHP and HTML code can be used on the same page.
A simple way to use this technique effectively is to remember that PHP goes inside of PHP blocks and HTML doesn’t.
To ouput html, use the _____ statement. _____(“html goes here”);
To ouput html, use the echo statement. echo(“html goes here”);
Variables start with a _
Variables start with a $
No variable ______ is required. You can just start using variables. e.g $someVar = 12
No variable declaration is required. You can just start using variables. e.g $someVar = 12
Concatenation uses a _____ NOT a ___ sign. e.g.
Concatenation uses a period NOT a plus sign.
Example:
$var1 = “I love”;
$var2 = “servers”;
echo($var1.$var2); //outputs “I loveservers”
Double quotes will _____ variables, and special characters, like \n or \t.
Single quotes will not and will ____ the literal string.
Double quotes will parse variables, and special characters, like \n or \t.
Single quotes will not and will output the literal string.
Example:
$name = “Joe”;
‘Hi I am $name’ //Hi I am $name
“Hi I am $name” //Hi I am Joe
Example of an if statement:
$test = 1;
if ($test == 1) {
echo (“we <b>passed</b> with a score of $test”); //note how you can embed a variable directly in a string
}
Arrays hold _____ _____ referenced by a ______ ______ .
Arrays hold multiple values referenced by a numerical index.
Example:
$myArray = array(“a”,”b”,”c”); //create an array
array_push($myArray,”d”); //add to end of array
array_pop($myArray) //removes and returns the last element of an array
count($myArray); //returns the array length
echo($myArray[0]); //prints out the first value in the array
Looping through a php array:
for ($i=0; $i