Quiz 7 - PHP 11,13,14

Quiz 7 - PHP 11,13,14

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

The easiest way to add the values in an array is to use

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (20)

Section 1

(20 cards)

The easiest way to add the values in an array is to use

Front

the array_sum function

Back

To create an object from a class named Cart that requires two arguments, you code

Front

new Cart($arg1, $arg2)

Back

Which of the following statements about associative arrays is NOT true?

Front

You can use a foreach loop to access the values of an associative array but not the indexes

Back

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

Front

return

Back

In PHP, function name duplications are likely to occur because

Front

all functions have global scope

Back

Gaps can be introduced into an array in all of the ways that follow, exept one. Which one is it?

Front

store an empty value in an array

Back

To prevent other classes from directly accessing the properties of a class, you can code them as private. Then, to make them available to other classes, you can code

Front

public methods to set and get their values

Back

To avoid the duplication of function names, you can

Front

Use namespaces

Back

When a new class extends a superclass, it inherits the properties and methods of the superclass. Then, it can

Front

override the inherited methods

Back

To code a constructor for a class named Cart that requires two arguments, you start with this code:

Front

public function __construct($arg1, $arg2) {

Back

To code a method within a class that sets the value for a private property named $name based on the argument that's passed to it, you start with this code:

Front

public function setName($value) {

Back

You can deal with gaps in an array in all but one of the following ways. Which one is it?

Front

Use the array_fill function to replace all gaps in the array with empty strings.

Back

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:

Front

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

Back

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

Front

func_get_args function

Back

Which of the following functions removes the next element in a LIFO array (also known as a stack)?

Front

array_pop

Back

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

Front

a value of either "heads" or "tails"

Back

When you use object-oriented techniques to implement the MVC pattern, the methods of the model return the data as either arrays or

Front

objects

Back

What will the value of the $totals_string variable be after the following code is executed? $totals = array(141.95, 212.95, 411, 10.95); $totals[2] = 312.95; $totals_string = ""; for ($i = 0; $i < count($totals); $i++) { $totals_string .= $totals[$i] . "|"; }

Front

141.95 | 212.95 | 312.95 | 10.95 |

Back

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

Front

can change the original variable without using a return statement

Back

Which of the following statements about an array of arrays is true?

Front

You can use both for loops and foreach loops to work with an array of arrays.

Back