You are on page 1of 7

62.

The ____ pattern is extremely useful for creating objects which watch the state of other
objects and respond to those changes.
Answer: Observer

63. In databased that do not support the AUTO_INCREMENT modifier, you must use a ____
instead to auto-generate a numeric incrementing key
Answer: LAST_INSERT_ID

64.
<?php
$array = array(
"a"=>"John",
"b"=>"Coggeshall",
"c"=>array(
"d"=>"John",
"e"=>"Smith"
)
);

function something($array)
{
extract($array);
return $c['e'];
}
print something($array);
?>
A. Smith
B. A PHP Warning
C. Coggeshall
D. NULL
E. Array
Answer: A

65. What does the following function do, when passwd two integer values for $p and $q?
<?php
function magic($p, $q)
{
return ($q == 0) ? $p : magic($q, $p % $q);
}
?>
A. Loops infinitely
B. Switches the values of $p and $q
C. Determines if they are both even or odd
D. Determines the greatest common divisor between them
E. Calculates the modulus between the two
Answer: E

66. When running PHP in a shared host environment, what is the major security concern
when it comes to session data?
A. Sessions on shared hosts are easily hijacked by outside malicious users
B. All of the above
C. You cannot use a custom data sotre in shared hosts
D. Session data stored in the file system can be read by other scripts on the same shared host
E. Users outside the shared host can access any site which created a session for them
Answer: D

67. Which of teh following functions will sort an array in ascending order by value, while
preserving key associations?
A. asort()
B. usort()
C. krsort()
D. ksort()

E. sort()
Answer: A

68. When executing system commands from PHP, what should one do to keep applications
secure? (choose 3)
A. Remove all quote characters from variables used in a shell execution
B. Avoid using shell commands when PHP equivlents are available
C. Hard code all shell commands
D. Escape all shell arguments
E. Escape all shell commands executed
Answer: BCD

69. Which of the following functions will trim leading and/or trailing white space from a
string? (choose 3)
A. ltrim()
B. rtrim()
C. wtrim()
D. trim()
E. str_replace()
Answer: ABD

70. Which of the following is not a valid fopen() access mode:


A. b
B. x
C. a
D. w
E. r+
Answer: A
It may be any of the following:
r Open for reading only; place the file pointer at the beginning of the file.

r+ Open for reading and writing; place the file pointer at the beginning of the file.
w Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero
length. If the file does not exist, attempt to create it.
w+ Open for reading and writing; place the file pointer at the beginning of the file and truncate the
file to zero length. If the file does not exist, attempt to create it.
a Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt
to create it.
a+ Open for reading and writing; place the file pointer at the end of the file. If the file does not exist,
attempt to create it.
x Create and open for writing only; place the file pointer at the beginning of the file. If the file already
exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If
the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags
for the underlying open(2) system call.
x+ Create and open for reading and writing; place the file pointer at the beginning of the file. If the
file already exists, the fopen() call will fail by returning FALSE and generating an error of level
E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|
O_CREAT flags for the underlying open(2) system call.

71. You can determine if you can seek an arbitrary stream in PHP with the ____ function?
Answer: stream_get_meta_data

72.
<?php
session_start();
if(!empty($_REQUEST['id']) && !empty($_REQUEST['quantity']))
{
$id = scrub_id($_REQUEST['id']);
$quantity = scrub_quantity($_REQUEST['quantity']);
$_SESSION['cart'][] = array(id=>$id, quantity=>$quantity);
}
/* */
?>
What potential security hole would this code snippet produce?

A. Cross-Site Scripting Attack


B. There is no security hole in this code
C. Code Injection
D. SQL Injection
E. Cross-Site Request Forgery
Answer: E

73. What is the primary difference between a method declared as static and a normal method?
A. Static methods can only be called using the :: syntax and never from an instance
B. Static methods do not provide a reference to $this
C. Static methods cannot be called from within class instances
D. Static methods dont have access to the self keyword
E. There is no functional difference between a static and non-static method
Answer: A * (Or B?)

74. When is it acceptable to store sensitive information in an HTTP cookie?


A. Only under extremely controlled situations
B. When the cookie is sent over a secure HTTP request
C. When it is encrypted
D. It is always acceptable
Answer: B

75. which of the following are not true about streams? (choose 2)
A. they are always seekable
B. when used properly they significantly reduce memory consumption
C. they can be applied to any data source
D. they are alwyas bi-directional
E. they can be filtered
Answer: AC (Im not sure about C or D is correct)

76. Which php.ini directive should be disabled to prevent the execution of a remote PHP
script via an include or require construct?
A. You cannot disable remote PHP script execution
B. curl.enabled
C. allow_remote_url
D. allow_url_fopen
E. allow_require
Answer: D

77. The ____ error level, which must be explicitally enabled in PHP 5, will warn you of
deprecated functionality that will be removed in a future PHP version.
Answer: E_DEPRECATED

78. Which of the following operations must occur prior to any output being sent to the client
(assume output buffering is disabled) (choose 3)
A. Modifying Session Data
B. Processing GET or POST data
C. Manipulating Cookie data
D. Starting a Session
E. Sending HTTP Headers
Answer: ABD * (Not sure A or C is right, be sure with BD)

79. The following code snippet displays what for the resultant array?
<?php
$a = array(1=>0, 3=>2, 4=>6);
$b = array(3=>1, 4=>3, 6=>4);
print_r(array_intersect($a, $b));

?>
A. 1=>0
B. 1=>3, 3=>1, 4=>3
C. 3=>1, 3=>2, 4=>3, 4=>5
D. 1=>0, 3=>2, 4=>6
E. An empty Array
Answer: E

80. Which of the following functions is used to determine if a given stream is blocking or not?
A. stream_get_blocking
B. stream_get_meta_data
C. stream_is_blocking
D. stream_get_blocking_mode
Answer: B

Get more Useful php certification tutorial


http://www.php-community.net

You might also like