How to read a single line, no matter how long from an file opened in the example below?
$fp = fopen( " my_file.txt " , " w " );
Which of the following function signatures is correct if you want to have classes automatically loaded?
What is the name of the PHP function used to automatically load non-yet defined classes?
What is the name of the method that can be used to provide read access to virtual properties in a class?
What can prevent PHP from being able to open a file on the hard drive (Choose 3)?
How many times will the function counter() be executed in the following code?
function counter($start, & $stop)
{
if ($stop > $start)
{
return;
} counter($start--, ++$stop);
}
$start = 5;
$stop = 2;
counter($start, $stop);
You want to allow your users to submit HTML code in a form, which will then be displayed as real code and not affect your site layout. Which function do you apply to the text, when displaying it? (Choose 2)
What will the following code print?
echo addslashes( ' I am a < b > small < /b > " HTML " string, which is
\ ' invalid\ ' < /u > . ' );
Can a private static member be accessed from a public static method of the same class?
The XML document below has been parsed into $xml via SimpleXML. How can the value of < foo > tag
accessed?
< ?xml version= ' 1.0 ' ? >
< document >
< bar >
< foo > Value < /foo >
< /bar >
< /document >
What is the output of the following code?
$a = ' a ' ; $b = ' b ' ;
echo isset($c) ? $a.$b.$c : ($c = ' c ' ). ' d ' ;
Which of the listed changes would you make to the following PHP 4 code in order to make it most compliant with PHP 5? (Choose 2)
< ?php
class Car {
var $model;
function Car($model) {
$this- > model = $model;
} function toString() {
return " I drive a $this- > model. " ;
}}
$c = new Car( ' Dodge ' );
echo $c- > toString();
? >
Which of the following code snippets is correct? (Choose 2)
a)
interface Drawable {
abstract function draw();
}
b)
interface Point {
function getX();
function getY();
}
c)
interface Line extends Point {
function getX2();
function getY2();
}
d)
interface Circle implements Point {
function getRadius();
}
What happens if you try to access a property whose name is defined in a parent class as private, and is not declared in the current class?
Identify the security vulnerability in the following example:
1 < ?php
2 mail( ' feedback@example.org ' ,
3 ' Feddback ' ,
4 ' Here is my feedback. ' ,
5 " From: {$_COOKIE[ ' email ' ]} " );
6 ? >
How many elements does the array $matches from the following code contain?
1 < ?php
2 $str = " The cat sat on the roof of their house. " ;
3
4 $matches = preg_split( " /(the)/i " , $str, -1,
PREG_SPLIT_DELIM_CAPTURE);
5 ? >
Which of the following functions are used to escape data within the context of HTML?
(Choose 2)
What is the content of $c after the following code has executed?
$a = 2;
$b = 3;
$c = ($a++ * ++$b);
Which of the following filtering techniques prevents cross-site scripting (XSS) vulnerabilities?
You have a variable $test that contains sub-strings divided by a dash ( " - " ). How can you put every sub-string into an array element easily?
One common security risk is exposing error messages directly in the browser. Which PHP configuration directive can be disabled to prevent this?
Which technique should be used to speed up joins without changing their results?
The following form is loaded in a recent browser and submitted, with the second list element selected:
< form method= " post " >
< select name= " list " >
< option > one < /option >
< option > two < /option >
< option > three < /option >
< /select >
< /form >
In the server-side PHP code to deal with the form data, what is the value of $_POST [ ' list ' ]?
Identify the security vulnerability in the following example:
1 < ?php
2 echo " Welcome, {$_POST[ ' name ' ]}. " ;
3 ? >
Which PHP function is used to validate whether the contents of $_FILES[ ' name ' ] [ ' tem_name ' ] have really been uploaded via HTTP ' ?
You work for a shared hosting provider, and your supervisor asks you to disable user scripts to dynamically load PHP extensions using the dl() function. How can you do this? (Choose 2)
What is the return value of the following code substr_compare( " foobar " , " bar " , 3);
Which of the following is used to find all PHP files under a certain directory?
You want to present the following formatted number: " 999.000.000,00 " . Which function call is correct?
After executing a query on a database server, PHP offers several functions to read the resulting lines, such as mysqli_fetch_assoc, pg_fetch_row, oci_fetch,etc.). If such functions do not return any rows, it means: (Choose 2)
What is the output of the following script?
1 < ?php
2 function fibonacci ($x1, $x2)
3 {
4 return $x1 + $x2;
5 }
6
7 $x1 = 0;
8 $x2 = 1;
9
10 for ($i = 0; $i < 10; $i++) {
11 echo fibonacci($x1, $x2) . ' , ' ;
12 }
13 ? >
Given the default PHP configuration, how can all of the parameters provided via GET be accessed in a form of a string?
The constructs for(), foreach(), and each() can all be used to iterate an object if the object
Which combination of the following filtering techniques prevents cross-site scripting (XSS) vulnerabilities?
What function can reverse the order of values in an array without the loss of key information?
Which of the following functions can help prevent session fixation vulnerabilities?
What is the output of the following code:
str_replace(array( " Apple " , " Orange " ), array( " Orange " , " Apple " ), " Oranges are orange and Apples are green " );
What is the name of the key in $_FILES[ ' name ' ] that contains the number of bytes of the uploaded file?
Is the following code piece E_STRICT compliant?
final class Testing {
private $test;
public function tester() {
return " Tested! " ;
}}
Given the following code, what will be the value of $a?
$a = array( ' a ' , ' b ' );
array_push($a, array(1, 2));
Consider the following code:
strspn($test, ' aeiou ' , 1);
The variable $test contains the string " You get certified " .
What will the function call return?
Type hinting in PHP allows the identification of the following variable types: (Choose 2)
You want to access the 3rd character of a string, contained in the variable $test. Which of the following possibilities work?(Choose 2)
Given the following code, what is correct?
function f(stdClass & $x = NULL) { $x = 42;
}
$z = new stdClass;
f($z);
var_dump($z);
The following form is loaded in a browser and submitted, with the checkbox activated:
< form method= " post " >
< input type= " checkbox " name= " accept " >
< form >
In the server-side PHP code to deal with the form data, what is the value of $_POST[ ' accept ' ]?
What will the $array array contain at the end of this script?
1 < ?php
2 function modifyArray ( & $array)
3 {
4 foreach ($array as & $value)
5 {
6 $value = $value + 1;
7 }
8
9 $value = $value + 2;
10 }
11
12 $array = array (1, 2, 3);
13 modifyArray($array);
14 ? >
You want to extract the pieces of a date string, which looks like this:
" 2005-11-02 " . Which of the following pieces of code will properly assign $year,
$month and $day with their respective values?