Variables, Constants, and Expressions Flashcards
What is a valid variable name?
A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
What is a special variable that can’t be assigned?
$this
What is a special variable that can’t be assigned?
$this
What is the difference between assigning by value and assigning by reference?
By default, variables are always assigned by value; the entire value of the original expression is copied into the destination variable. After assigning one variable’s value to another, changing one of those variables will have no effect on the other.
When you assign by reference, the new variable points to the original variable. Changes to the new variable affect the original, and vice versa.
To assign by reference, simply prepend an ampersand to the beginning of the source variable.
Only named variables (and not unnamed expressions or functions) may be assigned by reference.
Why are superglobals called superglobals?
Because they are automatically
Why are superglobals called superglobals?
Because they are automatically available in every scope.
Why are superglobals called superglobals?
Because they are automatically available in every scope.
What is the scope of variables within a user-defined function?
The scope is limited to that function.
Does the default scope span included and required files?
Yes.
What do you need to do to use a global variable within a function?
Declare it as global within the function.
What is a second way to access variables from the global scope?
Use the special PHP-defined $GLOBALS associative array. $GLOBALS is a superglobal.
What is a static variable?
.
What is a static variable?
A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope.
What is a recursive function?
A function which calls itself.
Can you assign values to a static variable if those values are the result of an expression.
No. This will result in a parse error.