Fichas
PHP Misc.
Fichas del conjunto (39)
- 1print_rPrints human readable information about a variable
- 2How to add add'l elements to an array$myRay [ ] = '...'
- 3Associative array - syntax$myRay = [
'one' => '1',
'two' => '2'
] ; - 4Add a value to an associative array - syntax$myRay[ 'three' ] = 'This is 3rd' ;
- 5Embed an associative array element into a double quoted string - syntaxecho "I said { $myRay[ 'index' ] } and they laughed ";
- 6Explicit Boolean valuesKeywords: 'True' and 'False'
- They are case INsensitive - 7Implicit Boolean 'falsey' Values- Zero as a number or string (0, 0.0, '0')
- An empty string ( ' ', " " )
- An empty array
- NULL (including unset variables)
- A SimpleXML object created from empty tags - 8$myVar = 'false' - Is $myVar implicitly true or false?$myVar is both implicitly true
- 9What does the ' ! ' logical operator do?Reverses the bool value of a variable or an expression
- 10Ternary Operator: Difference from JSThe ternary operator in PHP always assigns values directly to a variable
- 11Ternary Operator - Syntax$myVar = (condition) ? if true : if false ;
- 12Ternary Operator (short) - Syntax$myVar = myOtherVar ? : if falsey
- 13Null-coalesce Operator - Syntax$myVar = myVar2 ?? if false but not falsey
- 14Advantage to hiding content using PHP instead of JS/CSSThe source code will not show the hidden content if html embedded by php does not run
- 15What is the php concatenation operator?' . '
$myVar = "Jimi";
$myVar2 = " Hendrix";
$myConcat = $myVar . $myVar2;
echo $myConcat
// ' Jimi Hendrix ' - 16What is the combined concatenation operator?' .= '
- Adds something to an existing variable - 17What is the Modulus operator in PHP?' % '
- Returns the remainder of a division - 18What are the combined arithmetic operators in php?+=
-=
*=
/=
%=
**= - 19$numb = 30; $numb %= 4; What does $numb equal?2
- (change the numbers) - 20echo( ++$numb ); vs echo( $numb++ );++$numb will echo ($numb + 1)
$numb++ will echo $numb as is, then add 1 - 21Foreach loop - SyntaxV1
foreach ( $arr as $i ) { //code }
V2
foreach( $arr as $k => $v ) { //code } - 22The meaning of ' [ ] ' in the arguments list of the function descriptions in the php online documentationIt means that particular argument is optional.
(I imagine this is also the case with JS) - 23Meaning of the '&' in the php online documentationThat the function changes the original value of the variable that is passed to it
- 24Meaning of the first (green) variable type at the beginning of a function description on the php manualIt specifies the return value's variable type
- 25Function passing by value - Syntax - Resultfunction($var) {
//code
} ;
- Result: $var is not modified - 26Function passing by reference - Syntax - Resultfunction (&$var){
//code
}
- Result: $var is modified - 27var_dump( $a, [...$n] )- 'Dumps' information about a variable.
- $a = variable to be tested
- No return value
- I believe that 'dump', from the php manual, means 'displayed in the browser' - 28nl2br( $a )- Inserts html line breaks before all new lines in a string
-$a = the input string
- Return = the altered string - 29implode ($a, $b)- Returns a string of array elements, 'glued' together with a string
- $a = The 'glue' string between each array
- $b = The array to join/implode
- Return = a new string of the glued elements - 30What does 'callable' mean, at least in regards to the php documentation?That it is a function
- 31usort( &$a, $b );Sorts (and modifies) an array by a user defined function
- $a = The array to be modified
- $b = The user-defined callback function
- Return = True on success, False on failure - 32What is a callback?A function that is passed as an argument in order to manipulate data on the behalf of the main function
- 33How do you access an objects' properties/methods?The arrow operator
ex: $car1->color;
ex: $car1->drive(); - 34Spaceship Operator - Splain$res = $space <=> $ship
- If left is greater than right, returns 1
- If left equals right, returns 0
-If right is greater than left, returns -1 - 35substr($a ,$b, $c)- Returns part of a string
-$a: The string
-$b: The start index of the cut
-$c: OP, the length of the string - 36The includes() PHP language Construct - (similar to require)- Includes and evaluates the specified file
- Can have absolute paths + document relative paths, but not root relative paths - 37strlen( $a )- Returns an integer length of the string
- $a : The string being measured - 38in_array( $a, $b, $c )- Returns true/false if value $a is in array $b
-$a : The value to match
- $b : The array
- $c : OP. If 'true', then the function will also test the (data) types - 39array_push( &$a, $b... )- Pushes values onto the end of an array and returns the new length
-$a : The array to be modified
-$b: The value(s) to be added.
Información
- Descripción
- Fichas sobre PHP Misc., creado por Cosmo Brown el 20/10/2018.
- Creado por
- Cosmo Brown
- Visitas
- 2
- Valoración