Formative 3
Functions are designed to allow you to reuse the same code in different locations.
Group of answer choices
False
True
Sorts by a function
Group of answer choices
usort($array)
ksort($array)
kusort($array)
krsort($array)
$g = 200;
function a(){echo “5”;}
function b(){echo “4”;}
b();
what is the output of the code?
Group of answer choices
5
4
200
Error
$f = array(
'102' => "red",
'101' => "blue",
'100' => "yellow");
krsort($f);
print_r($f);
What is the output of the code?
Group of answer choices
Array ( [100] => yellow [101] => blue [102] => red )
Array ( [102] => yellow [101] => blue [100] => red )
Array ( [100] => red [101] => blue [102] => yellow )
Array ( [102] => red [101] => blue [100] => yellow )
What do you call a function inside of a function
Group of answer choices
Nested function
Loop function
Double function
Function fun
What is the keyword use to gain access a variable that is outside of the function?
Group of answer choices
Default
Global
Overall
Call
function is used to print the array structure.
Group of answer choices
print_a
print_s
print_f
print_r
is used to aggregate a series of similar items together, arranging and dereferencing them
in some specific way.
Group of answer choices
Function
Index
Array
Variable
Array can be used as ordinary array same as in C and C++ arrays.
Group of answer choices
True
False
You can pass values to a function and you can ask functions to return a value.
Group of answer choices
True
False
is a statement used to iterate or loop through the element in an array.
Group of answer choices
seteach()
everyone()
foreach()
everyeach()
functions are commonly used for debugging. The point of this of these functions is to help
you visualize what’s going on with compound data structures like arrays.
Group of answer choices
print_p() and var_add()
print_c() and var_info()
print_a() and var_size()
print_r() and var_dump()
foreach(____ as $value)
Group of answer choices
$arr
arr
array
arr$
Syntax for foreach
Group of answer choices
foreach($value){}
foreach($arr){}
foreach{}($arr as $value)
foreach($arr as $value){}
Each member of the array index references a corresponding value and can be a simple
numerical reference to the value’s position in the series, or it could have some direct
correlation to the value.
Group of answer choices
False
True
$g = 200;
function a(){echo “5”;}
function b(){echo “4”;}
a();
what is the value of the $g?
Group of answer choices
4
Error
200
5
Function can be put anywhere of the code
Group of answer choices
False
True
PHP array does need to declare how many elements that the array variable have.
Group of answer choices
False
True
$fruit = array(“orange”,”apple”,”grape”,”banana”);
What is the value of index 3?
Group of answer choices
orange
apple
banana
grape
Function can have a return value
Group of answer choices
True
False
$fruit = array(“orange”,”apple”,”grape”,”banana”);
What is the value of index 1?
Group of answer choices
orange
grape
apple
banana
$s = “variable”;
function f(){
global $s;
echo “function called ”;
echo “$s”;
}
f();
what is the output of the code?
Group of answer choices
function called variable
function called
function variable
function called undefined variable: s
Functions can only have 1 parameter
Group of answer choices
False
True
Array is used to aggregate a series of similar items together.
Group of answer choices
False
True
You can create your own function inside of a php code
Group of answer choices
False
True
ksort() and krsort() used to sort elements by values.
Group of answer choices
False
True
is a group of PHP statements that performs a specific task. Functions are designed to
allow you to reuse the same code in different locations.
Group of answer choices
Operators
Variables
Functions
Arrays
is declared inside a function and is only available within the function in which it is
declared.
Group of answer choices
Local variables
Static variables
Dynamic variables
Global variables
Syntax of a function
Group of answer choices
Param_function
Param (function name){}
Function name {param}
Function name(param){}
PHP array does not need to declare how many elements that the array variable have.
Group of answer choices
True
False
$mo = array(“jan”,”feb”,”mar”);
echo “<pre>”;
var_dump ($mo);
echo “</pre>”;
Check the code if valid or invalid?
Group of answer choices
Valid
Invalid
var_dump function is same as print_r function except it adds additional information about
the data of each element.
Group of answer choices
True
False
function disp(){
function disp2(){
echo “hello”;
}
}
disp();
disp2();
Group of answer choices
error
disp
hello
blank
$f = array(
'102' => "red",
'101' => "blue",
'100' => "yellow");
ksort($f);
print_r($f);
What is the output of the code?
Group of answer choices
Array ( [102] => yellow [101] => blue [100] => red )
Array ( [102] => red [101] => blue [100] => yellow )
Array ( [100] => yellow [101] => blue [102] => red )
Array ( [100] => red [101] => blue [102] => yellow )
$a[]=”mango”;
$a[]=”apple”;
$a[]=”banana”;
Check the code if valid or invalid?
Group of answer choices
Invalid
Valid
$t = 100;
function one(){
echo “1000”;
}
one();
what is the value of the $t after execute the code?
Group of answer choices
Error
1
100
1000
it is required to create a function name for a function
Group of answer choices
False
True
sort(), asort(), and ksort() functions are used to sort elements in the array in ascending
order.
Group of answer choices
True
False
$mo = array(“jan”,”feb”,”mar”);
echo “<pre>”;
print_r ($mo);
echo “</pre>”;
Check the code if valid or invalid?
Group of answer choices
Valid
Invalid
Functions can be user defined generally defined by the user of the program and
predefined that are build in using libraries.
Group of answer choices
False
True
Function count($val){
static $c = 0;
$c += $val;
echo $c;
}
count(4);
count(3);
What is the output of the code?
Group of answer choices
47
7
error
43
foreach($arr as ___ => $value){
//do something
}
Group of answer choices
$key
$var
$set
$get
You can insert CCS code inside of a function
Group of answer choices
False
True
$g = 200;
function a(){echo “5”;}
function b(){echo “4”;}
a();
what is the output of the code?
Group of answer choices
A
4
200
5
function keyword is used in PHP to declare a function.
Group of answer choices
False
True
Global Variables is declared inside a function and is only available within the function in
which it is declared.
Group of answer choices
True
False
Next
is used to retain the values calls to the same function.
Group of answer choices
Local variables
Static variables
Dynamic variables
Global variables
functions that are provided by the user of the program.
Group of answer choices
Program function
User function
User defined function
Predefined function
Array can be used as ordinary array same as in
Group of answer choices
Ruby
C and C++
Python
Java
function a($a,$b){
return $a+$b;
}
echo a(5,4);
what is the name of the parameter?
Group of answer choices
B
a
$b
$a
Local Variables is one that declared outside a function and is available to all parts of the
program.
Group of answer choices
True
False
$num=array(1,2,3,4,5);
foreach(num as $val){
echo $val;
}
Check the code if valid or invalid?
Group of answer choices
Invalid
Valid
$s = “variable”;
function f(){
echo “function called ”;
echo “$s”;
}
f();
what is the output of the code?
Group of answer choices
function called undefined variable: s
function called variable
function called
function variable
Sorts by value; keeps the same key
Group of answer choices
arsort($array)
rsort($array)
sort($array)
asort($array)
specify an array expression within a set of parenthesis following the foreach keyword.
Group of answer choices
False
True
Using foreach statement you can display both the keys and value of each element in the
array.
Group of answer choices
True
False
Array index in PHP can be also called as array storage
Group of answer choices
False
True
rsort(), arsort(), and krsort() functions are used to sort elements in the array in descending
order.
Group of answer choices
False
True
rsort(), arsort(), and krsort() functions are used to sort elements in the array in descending
order.
Group of answer choices
False
True
prints additional information about the size and type of the values it discovers
Group of answer choices
var_add()
var_info()
var_dump()
var_size()
To gain access to a variable that is outside from the function we use the global keyword.
Group of answer choices
False
True
Function can only do something without passing values.
Group of answer choices
True
False
Sorts by value; assign new numbers as the keys
Group of answer choices
arsort($array)
sort($array)
rsort($array)
asort($array)
A function that is declared inside a function is said to be hidden.
Group of answer choices
False
True
param – is the formal parameters of the function. Parameter must follow the rule of
naming dentifier.
Group of answer choices
False
True
$t = 100;
function one(){
echo “value”;
}
one();
what is the function name inside of the code?
$f = array(
'102' => "red",
'101' => "blue",
'100' => "yellow");
ksort($f);
print_r($f);
What is the key of the yellow?
Group of answer choices
102
Error
101
100
$g = 200;
function a(){echo “5”;}
function b(){echo “4”;}
ab();
what is the output of the code?
Group of answer choices
54
200
45
error
function a($a,$b){
return $a+$b;
}
echo a(5,4);
what is the output of the code?
Group of answer choices
9
5
4
Error
references a corresponding value.
Group of answer choices
Array number
Array setting
Array index
Array collection
Functions are limited to 1 per code only
You use can functions in different ways.
Group of answer choices
False
True
Sorts by value in reverse order; keeps the same key
Group of answer choices
arsort($array)
sort($array)
asort($array)
rsort($array)
function disp(){
function disp2(){
echo “hello”;
}
}
disp2();
Group of answer choices
error
hello
blank
disp
Function count($val){
$c = 0;
$c += $val;
echo $c;
}
count(10);
count(5);
What is the output of the code?
Array index is also known as Array Keys.
Group of answer choices
False
True
asort() and arsort() used to sort elements by keys.
Group of answer choices
False
True
sort() and rsort() does not maintain its index reference for each values.
Group of answer choices
True
False