Mastervincent
HRM3706 SUMMARISED NOTES
ICT3612 EXAM
PACK
FOR ASSISTANCE CONTACT
,Question 1
Which one of the following is the right way of defining a function in PHP?
1. function functionName(parameters) { function body }
2. function { function body }
3. data type functionName(parameters) { function body }
4. functionName(parameters) { function body }
Question 2
What output will the following PHP function produce?
<?php function calc($price, $tax
= ’’)
{
$total = $price + ($price * $tax);
echo "$total";
}
calc(42);
?>
1. 0
2. 42
3. 84
4. error
1
Downloaded by Vincent kyalo
()
, lOMoAR cPSD| 56105791
ICT3612/102/1/2018
Question 3
Which of the following are valid function names?
i. function()
ii. €()
iii. .function()
iv. $function()
1. only ii)
2. none of the mentioned
3. all of the mentioned
4. only i)
Question 4
What output will the following function produce?
<?php
function b()
{
echo "b is executed";
} function a() {
b(); echo "a is
executed"; b();
} a();
?>
1. b is executedb is executedb is executed
2. b is executeda is executedb is executed
3. b is executeda is executed
4. a is executed
Question 5
What output will the following function produce?
<?php
$op2 = "blabla";
function foo($op1)
{ echo
$op1;
echo $op2; }
foo("hello"); ?>
2
Downloaded by Vincent kyalo ()
, lOMoAR cPSD| 56105791
1. Hello
2. Helloblabla
3. Error
4. helloblablablabla
Question 6
Which one of the following PHP functions can be used to build a function that accepts any
number of arguments?
1. get_argv()
2. get_argc()
3. func_get_argv()
4. func_get_argc()
Question 7
What output will the following PHP code produce?
<?php function
addFive($num)
{
$num += 5;
}
function addSix(&$num)
{
$num += 6;
}
$orignum = 10; addFive(
$orignum );
echo "Original Value is $orignum<br />"; addSix(
$orignum );
echo "Original Value is $orignum<br />";
?>
1. Original Value is 15
Original Value is 21 2.
Original Value is 21
Original Value is 15 3.
Original Value is 10
Original Value is 16 4.
Original Value is 10
Original Value is 15
Question 8
3
Downloaded by Vincent kyalo
()
HRM3706 SUMMARISED NOTES
ICT3612 EXAM
PACK
FOR ASSISTANCE CONTACT
,Question 1
Which one of the following is the right way of defining a function in PHP?
1. function functionName(parameters) { function body }
2. function { function body }
3. data type functionName(parameters) { function body }
4. functionName(parameters) { function body }
Question 2
What output will the following PHP function produce?
<?php function calc($price, $tax
= ’’)
{
$total = $price + ($price * $tax);
echo "$total";
}
calc(42);
?>
1. 0
2. 42
3. 84
4. error
1
Downloaded by Vincent kyalo
()
, lOMoAR cPSD| 56105791
ICT3612/102/1/2018
Question 3
Which of the following are valid function names?
i. function()
ii. €()
iii. .function()
iv. $function()
1. only ii)
2. none of the mentioned
3. all of the mentioned
4. only i)
Question 4
What output will the following function produce?
<?php
function b()
{
echo "b is executed";
} function a() {
b(); echo "a is
executed"; b();
} a();
?>
1. b is executedb is executedb is executed
2. b is executeda is executedb is executed
3. b is executeda is executed
4. a is executed
Question 5
What output will the following function produce?
<?php
$op2 = "blabla";
function foo($op1)
{ echo
$op1;
echo $op2; }
foo("hello"); ?>
2
Downloaded by Vincent kyalo ()
, lOMoAR cPSD| 56105791
1. Hello
2. Helloblabla
3. Error
4. helloblablablabla
Question 6
Which one of the following PHP functions can be used to build a function that accepts any
number of arguments?
1. get_argv()
2. get_argc()
3. func_get_argv()
4. func_get_argc()
Question 7
What output will the following PHP code produce?
<?php function
addFive($num)
{
$num += 5;
}
function addSix(&$num)
{
$num += 6;
}
$orignum = 10; addFive(
$orignum );
echo "Original Value is $orignum<br />"; addSix(
$orignum );
echo "Original Value is $orignum<br />";
?>
1. Original Value is 15
Original Value is 21 2.
Original Value is 21
Original Value is 15 3.
Original Value is 10
Original Value is 16 4.
Original Value is 10
Original Value is 15
Question 8
3
Downloaded by Vincent kyalo
()