Question
Take the following HTML form.
1
2
3
4
| <form id="form" name="form" method="post">
<input type="text" name="number" value="0" />
<input type="submit" />
</form> |
What is the output of the following PHP code after the above form has been submitted, and why?
1
2
3
4
5
| if ($_POST['number'] === 0) {
echo 'number is zero';
} else {
echo 'number is not zero';
} |
Question
What does the $count variable equal after each of these loops?
1
2
3
4
5
6
| // Loop 1 - while
$count = 0;
while ($count < 0) {
++$count;
} |
1
2
3
4
5
6
| // Loop 2 - do while
$count = 0;
do {
++$count;
} while ($count < 0); |
Question
What does the following code do?
define("MY_CONSTANT", array(1,2,3,4,5));
Question
What is the difference between these two lines of code and can you produce the background code used for them?
1
2
3
4
5
| // Line 1
$MyClass->MyMethod();
// Line 2
MyClass::MyMethod(); |
Question
Write a PHP script that will print out the following text in the correct diamond shape.
1
2
3
4
5
6
7
8
9
10
| *
***
*****
*******
*********
*********
*******
*****
***
* |
Question
What does the following code snipped print?
1
2
3
| $a = 5;
$b = 'a';
print $$b; |