Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
68 Cards in this Set
- Front
- Back
What are PHP Arrays?
|
An array in PHP is actually an ordered map. A map is a type that associates values to keys.
|
|
What are some of the things that PHP files may contain?
|
HTML, Text, and Script
|
|
What is a Variable Scope?
|
The term "scope" refers to the places within a script where a particular variable is visible.
|
|
What does count() do?
|
Count all elements in an array, or something in an object.
|
|
What is an example of a count() array?
|
<?php
$food = array('fruits' => array('orange', 'banana', 'apple'), 'veggie' => array('carrot', 'collard', 'pea')); // recursive count echo count($food, COUNT_RECURSIVE); // output 8 // normal count echo count($food); // output 2 ?> |
|
What does the sort() array do?
|
This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
|
|
What is an example of a sort() array?
|
fruits[0] = apple
fruits[1] = banana fruits[2] = lemon fruits[3] = orange |
|
What does the asort() do?
|
Sort an array and maintain index association.
|
|
What is an example of a asort() array?
|
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); asort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> |
|
This is an example of what?
bool asort ( array &$array [, int $sort_flags = SORT_REGULAR ] ) |
asort() array
|
|
What does rsort() do?
|
Sort an array in reverse order.
|
|
What is this doing?
bool rsort ( array &$array [, int $sort_flags = SORT_REGULAR ] ) |
This function sorts the array from highest to lowest.
|
|
This is an example of what?
<?php $fruits = array("lemon", "orange", "banana", "apple"); rsort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?> |
rsort() array
|
|
What is the difference between asort() and rsort()?
|
asort() maintains an index association where as rsort() sorts the arrays in reverse order.
|
|
What does a PHP Loop do?
|
It tells the PHP how many times to execute a block of code.
|
|
How do you write a PHP Loop?
|
for (init counter; test counter; increment counter)
{ code to be executed; } foreach ($array as $value) { code to be executed; } |
|
What is an example of a Loop?
|
<?php
for( $x=0; $x<=10; $x++;) { echo "The number is: $x <br>"; } ?> |
|
What is an example of a foreach Loop?
|
<?php
$colors = array("red","green","blue","yellow"); foreach ($colors as $value) { echo "$value <br>"; } ?> |
|
What does trim() do?
|
Removes whitespace or other characters from the left side of a string.
|
|
What does addslashes() do?
|
Returns a string with backslashes in front of predefined characters.
|
|
What does explode() do?
|
Breaks a string into an array.
|
|
What does implode() do?
|
Returns a string from the elements of an array.
|
|
What is an alias of implode()?
|
join()
|
|
What does substr() do?
|
Returns a part of a string.
|
|
What are some other arrays related to substr()?
|
substr_compare() : Compares two strings from a specified start position
substr_count() : Counts how many times a substring appears in a string substr_replace() : Replaces a part of the string with another string |
|
What does strlen() do?
|
Returns the length of a string.
|
|
What does strpos() do?
|
Returns the position of the first occurrence of a string inside another string.
|
|
How do you specify a string?
|
Using single quotes ' '
|
|
What is the difference between require() and include()?
|
Require will produce a fatal error (E_COMPILE_ERROR) and stop the script.
Include will only produce a warning (E_WARNING) and the script will continue |
|
When would you use require()?
|
If you want to protect your code security, then use the require key to stop the flow pages.
|
|
When would you use include()?
|
When you want the pages to continue running with errors and all.
|
|
Where do you find parameters in PHP?
|
Parameters are specified after the function name, inside the parentheses.
|
|
What is this an example of and why?
<?php function ourFunction($x) { echo $x . ".<br />"; } $y = “black”; echo "My car color is "; ourFunction("white"); echo "My car color is "; ourFunction ("$y"); ?> |
It is a parameter and it can be verified after the functions call about the cars.
|
|
What does pass by reference mean?
|
You can pass a variable by reference to a function so the function can modify the variable.
|
|
What kind of things can be passed by reference?
|
Variables, i.e. foo($a)
New statements, i.e. foo(new foobar()) References returned from functions, i.e.: |
|
When & is used in a pass by it means it is a ...
|
Pass by Reference
|
|
What does & mean when used in a pass by reference?
|
It means that the original parameter must not be copied to a new variable. The parameter is referred inside the function by the reference
|
|
What is Returning references?
|
Returning by reference is useful when you want to use a function to find to which variable a reference should be bound.
|
|
What are a list of superglobals?
|
1/ $GLOBALS
2/ $_SERVER 3/ $_GET 4/ $_POST 5/ $_COOKIE 6/ $_FILES 7/ $_ENV 8/ $_REQUEST 9/ $_SESSION |
|
$_SERVER?
|
Array of server environment variables.
|
|
$_GET?
|
Array of variables passed to the script via the GET method.
|
|
$_POST
|
Array of variables passed to the script via the POST method.
|
|
$_COOKIE
|
Array of cookie variables.
|
|
$_FILES
|
Array of variables related to file uploads.
|
|
$_ENV
|
Array of environment variables.
|
|
$_REQUEST?
|
Array of all user input including the contents of input including $_GET, $_POST, and $_COOKIE but not including $_FILES.
|
|
$_SESSION
|
Array of session variables.
|
|
What are the 6 PHP Assignment Operators?
|
=
+= -= *= /= %= |
|
What are the 7 PHP Arithmetic Operators?
|
+ Addition
- Subtraction * Multiplication / Division % Modulus (division remainder) ++ Increment -- Decrement |
|
What are the 6 PHP Comparison Operators?
|
== (equal to)
!= (not equal) > (greater than) < (less than) >= (greater than or equal to) <= (less than or equal to) |
|
What are the 3 PHP Logical Operators?
|
&& and
|| or ! not |
|
What is the syntax of an If...Else statement?
|
if (condition)
code to be executed if condition is true; else code to be executed if condition is false; |
|
What is the syntax of an ElseIf statement?
|
if (condition)
code to be executed if condition is true; elseif (condition) code to be executed if condition is true; else code to be executed if condition is false; |
|
What is the syntax for a basic Numeric Array?
|
$example = array("Var1","Var2","Var3");
|
|
What is the syntax for assigning the ID values manually in a Numeric Array?
|
$example[0] = "Var1";
$example[1] = "Var2"; $example[2] = "Var3"; |
|
What is the basic syntax for an Associative Array?
|
$example = array("Var1"=>32, "Var2"=>30, "Var3"=>34);
|
|
What is an example of a multidimensional array?
|
$families = array
( "Var1"=>array ( "Sub1Var1", "Sub1Var2", "Sub1Var3" ), "Var2"=>array ( "Sub2Var1" "Sub2Var2" ), "Var3"=>array ( "Sub3Var1", "Sub3Var2", "Sub3Var2" ) ); |
|
What does a multidimensional array include?
|
In a multidimensional array, each element in the main array can also be an array. And each element in the sub-array can be an array, and so on.
|
|
What does an Associative Array include?
|
In an associative array, each ID key is associated with a value.
|
|
The PHP $_REQUEST variable can be used to get the result from form data sent with both the ___ and ____ methods.
|
$_GET and $_POST
|
|
The PHP _________ variable contains the contents of both $_GET, $_POST, and $_COOKIE.
|
$_REQUEST
|
|
The ______ variable is used to collect values from a form with method="post".
|
$_POST
|
|
What does a comma operator do? (,)
|
Separates function arguments and lists of items.
|
|
Who is new -> operators used?
|
Used to instantiate a class and access class members, respectively.
|
|
A PHP scripting block always starts with _____ and ends with __.
|
<?php
?> |
|
What is the syntax of a single-line comment in PHP? What is the syntax for a large comment block?
|
// to make a single-line comment
/* and */ to make a large comment block |
|
All variables in PHP start with what symbol?
|
$
|
|
Variables may contain _______, _______, or ______.
|
strings, numbers, or arrays
|