chap 13

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan 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.

(/=/, /equal/, /equals/)

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 returnsfunction 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 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

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

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

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

parameters

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

return

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

return

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

Which of the following is considered a scalar value?

string literal numeric literal Boolean value all of these

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

value

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

value


Set pelajaran terkait

Maternity Chpt 10 - Fetal Development 5-8

View Set

Virtualization/Hyper-V Facts/Cloud Computing Facts

View Set

5.2 Given a scenario, troubleshoot common cable connectivity issues and select the appropriate tools.

View Set

The Nature and Conservation of Energy

View Set

The Enlightenment Assignment and Quiz

View Set

Medical Terminology Chapter 20 Vocabulary

View Set