Académique Documents
Professionnel Documents
Culture Documents
PHP Test 1
1. Assume you would like to sort an array in ascending order by value while preserving key
associations. Which of the following PHP sorting functions would you use?
A) ksort()
B) asort()
C) krsort()
D) sort()
E) usort()
2. What function computes the difference of arrays?
A) array_diff
B) diff_array
C) arrays_diff
D) diff_arrays
3. Which of the following functions do not return a timestamp?
A) time()
B) date()
C) strtotime()
D) localtime()
E) gmmktime()
4. What will the following script output?
<?php
$time = strtotime ('2004/01/01');
echo date ('H:\i:s', $time);
?>
A) 00:00:00
B) 12:00:00
C) 00:i:00
D) 12:i:00
E) -1
5. Given a variable $email containing the string user@example.com, which of the following
statements would extract the string example.com?
A) substr($email, strpos($email, "@"));
B) strstr($email, "@");
C) strchr($email, "@");
D) substr($email, strpos($email, "@")+1);
E) strrpos($email, "@");
6. How does the identity operator === compare two values?
A) It converts them to a common compatible data type and then compares the resulting
values
Marks: 30
PHP Test 1
B) It returns True only if they are both of the same type and value
C) If the two values are strings, it performs a lexical comparison
D) It bases its comparison on the C strcmp function exclusively
E) It converts both values to strings and compares them
7. Variables always start with a ........ in PHP
A) Pond-sign
B) Yen-sign
C) Dollar-sign
E) Euro-sign
8. What is the value displayed when the following is executed? Assume that the code was
executed using the following URL:
testscript.php?c=25
<?php
function process($c, $d = 25)
{
global $e;
$retval = $c + $d - $_GET['c'] - $e;
return $retval;
}
$e = 10;
echo process(5);
?>
9. Which of the following will not combine strings $s1 and $s2 into a single string?
A) $s1 + $s2
B) "{$s1}{$s2}"
C) $s1.$s2
D) implode(' ', array($s1,$s2))
E) All of the above combine the strings
10. 5. String values must be enclosed in ......
A) single quotes
B) double quotes
C) both A and B
D) none of above
11. 7. PHP ..... demand that you declare a data type when you create a variable.
A) does
B) does not
12. 10. PHP considers the following values as False
A) the integer 0
Marks: 30
PHP Test 1
Marks: 30
PHP Test 1
Shrek
a is 4 and b is 3.
c.
Both are 3.
d.
Both are 4.
19. What will be the output of the following PHP code if date is 24/02/2008?
<?php
$date = new DateTime();
echo $date->format('l,F,js,Y')
?>
Marks: 30
PHP Test 1
Sunday, 24 02 2008
d.