• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/113

Click to flip

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;

113 Cards in this Set

  • Front
  • Back
Where is PHP's syntax derived?
Mostly C, some Perl with Java for object-oriented additions.
What does PHP's Standard Tag look like?
<?php ... ?>
What is the best PHP tag to use?
Standard, because of portability, backwards compatibility and cannot be disabled in conf. file.
What does PHP's Echo Tag look like?
<?= $variableToEcho; ?>
What does PHP's Short Tag look like?
<? ... ?> Used to be standard but conflict with XML.
What does PHP's Script Tag look like?
<script language="php"> ... </script> Introduced so HTML editors could ignore PHP code.
What does PHP's ASP Tag look like?
<% ... %> Nobody knows why this was created.
Which PHP tags are deprecated?
Short, Script and ASP
What are the 5 types of PHP Tags?
Standard, Echo, Short, Script, ASP
Why are newlines automatically stripped outside of PHP tags?
Newlines are used as separators between HTTP response's header and data portions. Newlines can cause unexpected problems.
Why should you omit a closing PHP tag from the end of a file?
It prevents spurious output, like newlines that can alter response headers, from an include file.
How can you write a single line comment?
Double forward slash or hashtag.
How can you end a single line comment?
Newline or closing PHP tag.
Is PHP a whitespace sensitive language?
No, except for obvious exceptions.
What is a code block?
Any series of statements between two braces.
What can't the echo construct do?
It cannot give a return value because it is not a function. On the other hand, the print construct acts like a function as it always returns 1.
What's the difference between die() and exit()?
Nothing.
What does the die construct do?
It terminates the script and outputs either a string a numeric status value to the process that called the script.
What are scalar data types?
They are data types that can only contain one value at a time. Boolean, Int, Float and String.
What is a boolean data type?
A value that can only be either true or false
What is an int data type?
A signed numeric integer value
What is a float data type?
A signed floating-point value
What is a string data type?
A collection of binary data
What are the four notation types for numeric values?
Decimal, Octal, Hexadecimal and Binary. All notations are converted to decimal when using echo and print.
What are the two notation types for floating-point values?
Decimal and Exponential (5E3 = 500)
How can you ensure numeric precision when desired?
Use PHP plugin like BCMath, not PHP's built-in data types.
What is a string?
Binary data that could be text, images, music, etc.
What happens to a number if it is converted to boolean?
If the number was 0, then FALSE, otherwise TRUE.
What happens to a string if it is converted to boolean?
If the string was empty or just a zero then FALSE, otherwise TRUE
What happens if a string is converted to an int?
It becomes 0.
What are the compound data types?
Arrays and Objects
When is a variable = NULL?
When it is explicitly set to null or if it has never been set.
What is the resource data type?
It indicates external resources that are not used natively by PHP like handling files and images.
What is type casting?
Explicitly setting the data type by preceding the variable with the data type in parentheses (int) $x
What is a variable?
A temporary storage container for all data types.
Is PHP loosely typed?
Yes, variables will change data type as needed.
What can a variable name start with?
A letter or underscore only.
What happens if you cast a scalar type variable to an array?
It gets set to an array where the 0 key is equal to the value.
What is the class of an array that has been cast to an object?
stdClass
What are the 4 type casting functions?
intval(), floatval(), boolval(), settype()
What are the normal detect variable functions?
is_int(), is_float(), is_string(), is_bool(), is_null(), is_array(), is_object()
How is is_numeric() different than other detect variable functions?
It will return true regardless of data type as long as it is a number.
If $name = 'foo' and $$name = 'bar', what does echo $foo display?
bar
How can you circumvent naming constraints?
$name = '123', $$name = '456', Then echo ${'123'} = '456'
What does print_r() do?
It prints the array or object type and then lists the keys or properties and their values.
What does var_dump() do?
Same as print_r() but it also gives the data type and length, as well as differentiating between FALSE and NULL
What does debug_zval_dump() do?
It outputs the internal engine representation of a variable
What does var_export() do?
Outputs a string representation of a variable, re-creating the original and can be saved as a copy.
What does isset() do?
Returns TRUE if variable exists and is not NULL
What does empty() do?
Returns TRUE if passed null or any variable or expression that evaluates to false, 0 or an empty array().
What type of values can constants contain?
Scalar values, including magic constants, only.
What does define() do?
defines a constant: devine('CONSTANT_NAME', 'scalar value')
Can you define a constant with a constant?
Yes, but only after PHP 5.6
What are Arithmetic Operators?
Addition (+), Subtraction (-), Multiplication (*), Division (/), Modulus (%), Power (** added PHP 5.6)
What are unary operators?
Operators that only accept one operand, like incrementing and decrementing.
If $a is an integer, What does $a++ do?
The interpreter will return the value of $a and then increase $a by one.
If $a is an integer, What does ++$a do?
The interpreter will increase $a by one and then return its new value.
Why should you use increments, decrements and $$ variables sparingly?
They can make your code hard to understand for other programmers.
What operands can use increment and decrement operators
Only variables, hard-coded values and expressions will throw an error.
What happens if you try to concatenate strings with the += operator?
Both strings are converted into numeric value and then added together.
What is a bitwise operator?
They allow you to manipulate bits of data, converting all operands into integers before execution.
What is the ~ operator?
Bitwise NOT operator that negates each bit.
What is the | operator?
Bitwise OR operator that sets a bit if either one or both operand bits is set.
What is the ^ operator?
Bitwise XOR operator that sets a bit iff one of the operand bits is set.
What is the << operator?
Bitwise LEFT SHIFT operator that shifts first operand bits to the left by a number equal to the right operand
What is the >> operator?
Bitwise RIGHT SHIFT operator that shifts first operand bits to the right by a number equal to the right operand
What are bitwise shift operators good for?
They are a very efficient way to multiply integers by powers of 2.
What would 2 << 33 equal on a 32 bit machine?
4
What is the assignment operator?
It assigns a value to a variable (=)
What happens if you combine the assignment operator with another operator?
It performs the operation on the value and then assigns the new value to the variable.
By default how do assignment operators assign a value?
If the value is an object, by reference. Otherwise, by value.
How would you assign a variable by reference?
$a = &$b;
What is the difference between a variable assigned by reference and a variable assigned by value?
By reference if the right-hand variable's value changes, so does the left hand variable's value. By value, if the right=hand variable's value changes, the left hand's value does not.
Why should you use variables passed by reference sparingly?
1. PHP variables stay in scope a long time. 2. by-reference activity is slower in PHP.
What is the Equivalence Operator?
(==) Evaluates to true if the two operands are equivalent, meaning that they can be converted to a common data type in which they have the same value but are not necessarily of the same type.
What is the Identity Operator?
(===) Evaluates to true only if the operands are of the same data type and have the same value.
What is the Not-equivalent operator?
(!=) Evaluates to true if the two operands are not equivalent, without regard to their data type.
What is the Not-identical operator?
(!==) Evaluates to true if the two operands are not of the same data type or do not have the same value.
What happens if you use string values in an inequality operator?
The values are converted into binary then assessed for inequality..
What happens if you use non-boolean operands in logical operators?
The operands are converted to boolean before execution.
If $a = FALSE and $b is not set, Which operation will throw a warning? 1. ($a && $b->prop) 2. ($b->prop && $a)
#2 only, because in #1 $b->prop is never checked as the operation ended once $a was evaluated.
What is the @ operator?
When prepended to an expression, it suppresses almost all errors.
What operator lets you make unix commands?
The backtick operator: $a = `ls -l`
Why shouldn't you mix |, || and OR in an expression?
They all have different precedence (Think PEMDAS)
What is the difference between 'else if' and 'elseif'
Nothing
What is the ternary operator for an if-then-else statement?
(condition) ? 'then execution' : 'else execution';
What conditional structure should you use if you have to check a single variable through several possible values?
Switch Statement
What is the 'fall-through' feature of a switch statement?
It's when you intentionally leave out the 'breaks;' so the input will execute multiple cases.
What's the difference between 'while' and 'do while' loops?
while' checks the condition before execution, 'do while' checks condition after execution ensuring that the code block will be executed at least once.
What does the PHP+EOL constant contain?
Your OS's end of line marker.
What's the difference between a 'for' and a 'while' loop?
The 'for' loop has a built-in counter.
What does 'break' do?
It exits the current loop?
What does the optional break parameter do?
It allows you to exit n nested loops. By default n = 1.
What can happen if you do not terminate 'break' with a semicolon?
You may exit out of multiple loops by mistake.
What does 'continue' do?
It exits the current iteration of a loop and moves to the next one.
Where can you declare a namespace?
Only at the very top of the file. It may be preceded by opening PHP tag or a declare statement.
What code is affected by namespaces?
Classes, Traits, Interfaces, Functions and Constants.
What are some benefits of namespaces?
Avoid naming collisions and long names.
What happens if you declare a namespace more than once?
The code in each declaration is included in the namespace.
How can you place code in global scope?
Use an anonymous namespace (Must use curly braces)
How can you define a sub-namespace?
With the backslash operator.
Can you declare namespace Ds\String\Tools if Ds\Tools is undefined?
Yes
If a class, MyClass has namespace Ds\String, what is the fully qualified name for MyClass?
Ds\String\MyClass
How can I call class ThisClass if I'm in Ds\String\MyClass and ThisClass is not in Ds\String?
Prepend it with a backslash. (\ThisClass)
Within a namespace, what happens if you call a global function?
As long as the function isn't defined in the namespace, it will call the global function, unless you've tried to 'use' the function from another namespace.
When outside a namespace, what will happen if you call \foo\bar\strlen if it doesn't exist?
It will fall back to the global strlen function with no error.
For Ds\String\MyClass, do I have to instantiate it with the fully qualified name?
Yes, unless you've previously stated 'use \Ds\String\MyClass'
What scope does 'use' have?
It only applies to the file in which it is declared, it doesn't affect any other files even when included.
How can I include all sub-elements from the Ds\String namespace?
use Ds\String' then instantiate a sub-element with String\MyElement
How can you dynamically refer to a namespaced class?
You must use the fully-qualified namespace.
What does the CLASS construct do (case-insensitive)?
It returns the fully qualified name of a class.
How do you create a class alias?
use Ds\String\MyClass as String;'
How can you import a namespaced function or constant?
use function(const) Unicode\TOols\FunctionOrConstantName