Variable Flashcards

1
Q

What function is used to get string value of a variable ?

A

Use strval( $val ) to get string value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What function would you use to get integer value of variable?

A

Use Intval($val ) to get integer value .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What function would you use to format a nmber as a currency string

A

Use money_format ( string $format , float $number )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What function can you use to can set locale value ?

A

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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What function is used to Find whether the type of a variable is float

A

is_float()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do you use to set a variables type?

A

settype ( $var , type )

— Set the type of a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What function is used to serialise a string?

A
string serialize ( mixed $value )
- Generates a storable representation of a value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is used to dump information on screen?

A

var_dump()

— Dumps information about a variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How would you exportable a POST value into a global scope?

A

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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What function would you use to get an multidimensional of defined variables ?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you determine if an variable is empty?

A

bool empty ( mixed $var )

-Determine whether a variable is considered to be empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens when the following code is run?

A

Output is lastname , email , phone

Implode (string , array) function joins a string with array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
What happens when the following code is run?
$input = alien ;
echo str_pad($input, 10, "-=", STR_PAD_LEFT);
A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the function isset() used for?

A

The function is used to return Boolean if the variable is set and not NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly