Int Web Prog Ch13

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which character is used before an argument to specify that the variable is being passed to a PHP function by reference?

&

To create a default value for a parameter in the parameter list of a function, you code a/an ________________ sign after the parameter name followed by the default value.

=

Given this function: $compare_function = function(float $left, float $right) { return $left <=> $right; }; what will happen when the following statement is executed? $result = $compare_function(12.5, 12);

The function will return 1.

Given this function: function get_tax(int $subtotal, float $tax_pct) : float { $tax = $subtotal * $tax_pct; return $tax; } what will happen when the following statement is executed if strict types mode is set? $tax = get_tax(10.5, .08);

The function will throw an exception because the subtotal isn't an int value.

Given this function: function get_tax(int $subtotal, float $tax_pct) : float { $tax = $subtotal * $tax_pct; return $tax; } what will happen when the following statement is executed if strict types mode isn't set? $tax = get_tax(10.5, .08);

The function will truncate $subtotal to 10 and return .80.

Which of the following is NOT true about type declarations?

They were introduced with PHP 7.

To avoid the duplication of function names, you can

Use namespaces

The function that follows returns function coin_toss() { if (mt_rand(0, 1) == 0) { $coin = 'heads'; } else { $coin = 'tails'; } return $coin; }

a value of either "heads" or "tails"

In PHP, function name duplications are likely to occur because

all functions have global scope

Which of the following is considered a scalar value?

all of these (string literal, numeric literal, Boolean value)

Which type of PHP function does not have a name?

anonymous

To call a function, you code the function name followed by a set of parentheses that contains a list of the required ________________.

arguments

When you call a function, you can pass ________________ as values that correspond with the parameters of the function.

arguments

Which method of passing a variable allows the function to change the value of the variable?

by reference

Which of the following is a function that is passed as an argument to another function?

callback

If you create a function that passes an argument by reference, the function

can change the original variable without using a return statement

Which of the following is a nested function that has access to the outer function's local variables?

closure

A function library is just a/an ________________ that contains one or more functions.

file

All of the arguments that are passed to a function are available in an array that can be accessed by using the

func_get_args function

If you create a function with a variable number of parameters, you need to use a PHP ________________ to get an array of the arguments that are passed to the function.

function

To create a function named randomize that has one parameter that has a default value of 5 and one required parameter that's passed by reference, you start the function like this:

function randomize(&$parm1, $parm2 = 5) {

In PHP, all functions have ________________ scope.

global

Within a function, you can use the ________________ keyword if you need to refer to a variable that's declared outside the function.

global

A variable declared inside a PHP function would be considered a ____________ variable.

local

If you declare a variable within a function, the variable has ________________ scope.

local

To avoid collisions of function names, you can create a/an ________________ for storing your functions.

namespace

When creating functions, you can include ______________ that are located inside parentheses after the function name.

parameters

Within a function, you can end the function and pass the result back to the calling statement by coding a/an ________________ statement.

return

With PHP 7 and later, in addition to declaring the type of a parameter for a function as an object, you can declare the type as a/an ________________ value.

scalar

Which term describes locations in the code that have access to a variable?

scope

You can use the ________________ operator with PHP 7 or later compare two values.

spaceship

By default, all arguments for PHP functions are passed by ________________.

value

By default, all arguments passed to PHP functions are passed by ________________.

value


Kaugnay na mga set ng pag-aaral

CH 14 PART 3 TENSOR FASCIAE LATAE (TFL)

View Set

Chapter 7, Legal Dimensions of Nursing Practice

View Set

1140 practice questions exam 4 immune system

View Set

EPY 351 final comprehensive quiz

View Set