PHP Flashcards
What does fmod() do?
Floating Modulus returns the modulus of a floating point number. number1 % number2.
What is the syntax for floating point modulus?
fmod($x, $y)
- x will be divided by y
What does XOR do?
Evaluates to true if one and only one condition is true.
What is || and how else can it be written?
It checks if at least 1 condition is true and if so returns true it can also be written as OR
What does && and how else can it be written?
Checks if both conditions are true and if so evaluates to true if one condition is false than then it evaluates to false. it can also be written as AND
What is a ternary operator?
A short hand for writing if constructs.
What is the syntax of a ternary operator?
$x = (CONDITION) ? TRUEBLOCK : FLASEBLOCK
What is a constant?
Constants are basically variable that can’t be redefined.
What is the syntax for creating a constant?
define(‘CONSTANT_NAME’, ‘CONSTANT_VALUE);
What is the php syntax for an array?
$x = array(item1, item2, item3,);
What is the shorthand syntax for an array and when can it be used?
$x = [item1, item2, item3,]; and it can be used as of php 5.4.
What is a statement?
A statement is the the shortest piece of code that communicates a complete thought.
When is the semicolon used?
At the end of a statement. It acts like a period.
what does strlen( ) do?
It will give you the length of the string that is passed to the function.
what does substr( ) do?
Selects a piece of a string. It is first passed a string, then a start point and the number of characters to return. i.e. substr(“Hello” 0, 3);
Would print “Hel”
what does strtoupper( ) do?
Converts the string it is passed to upper case.
What does strtolower( ) do?
Converts the string it is passed to lower case.
What does strpos( ) do?
It checks if a substring is in a string and gives it’s index/position.
What does round( ) do and what are it’s parameter.
round( ) is used to round a floating numer up or down.
It’s first parameter is the number or number stored in a variable that is to be rounded and the second is the decimal place of where to round to.
What does ceil( ) do?
Forces a floating point number to round up.
What does floor( ) do?
Forces a floating point number to round down.
what does rand( ) do?
Produces a random number between the two parameters set. i.e. rand(1,5);
would return a random number between 1 and 5.
what does array_push( ) do?
Adds an item to an array. The first parameter is the array to add to and the second is what to add.
what does count( ) do?
Returns the number of items in an array.
What does join( ) do?
It joins the items of an array together it has to parameter the “glue” and the “array”. The glue is what you want to have between the array elements and the array is the array you want to perform the function on.
i.e. join(“test “, $theArray);
would return all the elements in side the $theArray array and join them together with test (and then a space).
what does sort( ) do?
It sorts the elements in an array from lowest to highest or A - Z.
What does rsort( ) do?
It sorts the elements in an array from highest to lowest or from Z - A.