Variable Flashcards
What function is used to get string value of a variable ?
Use strval( $val ) to get string value
What function would you use to get integer value of variable?
Use Intval($val ) to get integer value .
What function would you use to format a nmber as a currency string
Use money_format ( string $format , float $number )
What function can you use to can set locale value ?
Use setlocale() to set to the appropriate default locale before using this function.
The LC_MONETARY category of the locale settings, affects the behavior of this function.
E.g setlocale(LC_MONETARY, ‘en_US’); or
setlocale(LC_MONETARY, ‘it_IT’);
echo money_format(‘%.2n’, $number) . “\n”;
setlocale(LC_MONETARY, 'en_GB'); $fmt = 'The final value is %i (after a 10%% discount)'; echo money_format($fmt, 1234.56) . "\n"; // The final value is GBP 1,234.56 (after a 10% discount)
What function is used to Find whether the type of a variable is float
is_float()
What do you use to set a variables type?
settype ( $var , type )
— Set the type of a variable
What function is used to serialise a string?
string serialize ( mixed $value ) - Generates a storable representation of a value
What is used to dump information on screen?
var_dump()
— Dumps information about a variables
How would you exportable a POST value into a global scope?
bool import_request_variables ( string $types [, string $prefix ] )
- Imports GET/POST/Cookie variables into the global scope. It is useful if you disabled register_globals, but would like to see some variables in the global scope.
What function would you use to get an multidimensional of defined variables ?
array get_defined_vars ( void )
-This function returns a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables, within the scope that get_defined_vars() is called.
How do you determine if an variable is empty?
bool empty ( mixed $var )
-Determine whether a variable is considered to be empty.
What happens when the following code is run?
Output is lastname , email , phone
Implode (string , array) function joins a string with array.
What happens when the following code is run? $input = alien ; echo str_pad($input, 10, "-=", STR_PAD_LEFT);
output produces
“-=-=-Alien”
str_pad ( , number_of_spaces , , position)
- function adds space to string , depending added parameter it positions it left STR_PAD_LEFT, or right STR_PAD_RIGHT. And can add string
What is the function isset() used for?
The function is used to return Boolean if the variable is set and not NULL