PHP Flashcards
When clients request a page containing a server-side script, the ______ processes the scripts, then returns the HTML to the client. For example, a PHP page is not processed by the _______. Instead, it’s interpreted by the ______, that can process PHP scripts and then returns the HTML page to the ______.
server, browser, client
What Is The Current Major Version Of PHP?
5.x
When PHP runs its code, it runs from top to bottom.
true
All statements end with a _________ character.
semicolon
The PHP interpreter ignores whitespace.
true
How many data types are there in PHP?
7
Name the 7 data types in PHP.
Integers, Floats, Strings, Arrays, Booleans, Objects, Resources
What built-in internal function outputs the data type?
gettype
Most strings in PHP are “x” base index.
0
$greeting = "Hello World"; $greeting{0} = "J"; // what is the value of $greeting?
Jello World
Anything that is a ___-____ value will always be considered “true”.
non-zero
Anything that’s empty in any way is always considered _____.
false
A ________ is unchangeable whereas a ________ is varying. _________ are something we may eventually want to modify; a temporary storage location for information in a program.
constant, variable
Variables begin with a ______ sign character whereas constants are typically identified by all ____.
dollar, caps
A string is a series of characters, where a character is the same as a byte.
true
A ________ is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script. A ________ is ____-_________ by default. By convention, ________ identifiers are always_________.
constant, case-sensitive, uppercase
$arr = array(“Apples”, “Oranges”, “Blueberries”);
print_r($arr); // ___ _____ pairs.
Array ( [0] => Apples [1] => Oranges [2] => Blueberries )
key value
$arr = []; // _________ method.
shorthand
$arr = array( 12, “green”, 4.65, myFunc(), true ); // _____ data ____ array.
mixed, type
$eye_colors[] = ‘hazel’; // what is the result of this statement?
Append key value pair to end of array.
$arr = array(“apples”, “oranges”, “bananas”); // what type of array is this?
Indexed / Numeric Array
Associate arrays allow us to use a _______ as a key.
string
$fav_clr = array(“michel” => “green”); // what type of array is this?
Associative Array
Ternary is pronounced “turn-a-ree”.
true
Name the 8 most commonly used operator types.
comparison, concatenation, unary, binary, ternary, arithmetic, casting, assignments
=== // Strict ________ / __________ operator. Equal in both value and type.
Strict equality / identical operator.
&&, ||
Logical operators.
There are 4 looping constructs, what are they?
for, foreach, while, do…while
By default, PHP uses the “passing by _____” method of passing an argument.
true
There how many methods of passing an argument in regards to how the argument value is affected by a function?
2
When referring to passing arguments to functions, in which method are the argument values not at all affected by the function outside of that function scope?
“passing by value”
Passing arguments by “reference” means the value of an argument if modified by the function scope, will be modified outside the function scope as well. This method of passing arguments is referred to as what?
“passing by reference”
The statement $func() is referred to as what in the following code block?
function answer() { return 42; } $func = 'answer'; $func();
Variable function
_________ _________ are functions with no name. These functions are capable of accessing variables outside of the function scope.
Anonymous functions
A semicolon is required at the end of this type of function.
Anonymous function
echo “Hello $friends.”; // while double quotes ________ variables in a string, single quotes do not.
evaluate
In an anonymous functions, to pass through a variable outside the function scope, you use the ___ keyword and pass it the argument variable.
// Example $name = "Michel";
$greet = function() ___($name) {
return “Hello $name.”;
};
use
What keyword or method can we use to pass a value into a closure or anonymous function?
the “use” keyword
a ________ is what we can a variable declared inside a class.
property
To implement an interface, the __________ operator is used.
implements
True or false: The constructor method has to be called __construct().
true
___________ is a way for one class to take on the properties or methods of another class.
Inheritance
A parent class is also sometimes referred to as a __________ while a child class can be referred to as a ________.
superclass, subclass
The ______ keyword lets you use a class ________ or ______ without having to create an instance of that class.
static, property, method
An associative array makes use of ___ and _____ pairs.
key => value
You can write php in either a __________ (old fashioned) or OOP way.
procedural