-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathfunctions.yml
More file actions
95 lines (92 loc) · 4.58 KB
/
functions.yml
File metadata and controls
95 lines (92 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
category: Functions
questions:
-
question: 'What is the best way to ensure that a user-defined function is always passed an object as its single parameter?'
answers:
- {value: 'function myfunction(stdClass $a)', correct: true}
- {value: 'function myfunction($a = stdClass)', correct: false}
- {value: 'Use is_object() within the function', correct: false}
- {value: 'There is no way to ensure the parameter will be an object.', correct: false}
- {value: 'function myfunction(Object $a)', correct: false}
-
question: |
What does the following function do, when passed two integer values for $p and $q?
function magic($p, $q) {
return ($q == 0) ? $p : magic($q, $p % $q);
}
answers:
- {value: 'Loops infinitely.', correct: false}
- {value: 'Switches the values of $p and $q.', correct: false}
- {value: 'Determines if they are both even or odd?', correct: false}
- {value: 'Determines the greatest common divisor between them.', correct: true}
- {value: 'Calculates the modulus between the two.', correct: false}
-
question: |
What would go in place of ?????? below to make this script execute without a fatal error?
$a = 1;
$b = 0;
/* ?????? */
$c = $a / $b;
answers:
- {value: 'quit();', correct: false}
- {value: 'die();', correct: true}
- {value: 'stop();', correct: false}
- {value: '__halt_compiler();', correct: true}
- {value: 'exit();', correct: true}
-
question: 'What is the difference between the ``include`` and ``require`` language constructs?'
answers:
- {value: 'Require constructs can''t be used with URL filenames', correct: false}
- {value: 'Include constructs cause a fatal error if the file doesn''t exist', correct: false}
- {value: 'There is no difference other than the name', correct: false}
- {value: 'Include constructs are processed at run time; require constructs are processed at compile time', correct: false}
- {value: 'Require constructs cause a fatal error if the file can''t be read', correct: true}
-
question: |
What would you replace ??????? with, below, to make the string Hello, World! be displayed?
function myfunction() {
/* ??????? */
echo $string;
}
myfunction("Hello, World!");
answers:
- {value: 'There is no way to do this.', correct: false}
- {value: '$string = $argv[1];', correct: false}
- {value: '$string = $_ARGV[0];', correct: false}
- {value: 'list($string) = func_get_args();', correct: true}
- {value: '$string = get_function_args();', correct: false}
-
question: |
What is the output of the following?
$a = 20;
function myfunction($b) {
$a = 30;
global $a, $c;
return $c = ($b + $a);
}
echo myfunction(40) + $c;
answers:
- {value: '120', correct: true}
- {value: 'Syntax Error', correct: false}
- {value: '60', correct: false}
- {value: '70', correct: false}
-
question: |
What is the output of the following function?
function &find_variable(&$one, &$two, &$three) {
if ($one > 10 && $one < 20) return $one;
if ($two > 10 && $two < 20) return $two;
if ($three > 10 && $three < 20) return $three;
}
$one = 2;
$two = 20;
$three = 15;
$var = &find_variable($one, $two, $three);
$var++;
echo "1: $one, 2: $two, 3: $three";
answers:
- {value: '1: 2, 2: 20, 3: 15', correct: false}
- {value: '1: 3, 2: 21, 3: 16', correct: false}
- {value: '1: 2, 2: 21, 3: 15', correct: false}
- {value: '1: 3, 2: 20, 3: 15', correct: false}
- {value: '1: 2, 2: 20, 3: 16', correct: true}