PHP Test

1. Which PHP function opens a file for reading only?
Answers:
• fopen("c:\\test\\time.txt" , "w");
• open("c:\\test\\time.txt");
• fopen("c:\\test\\time.txt" , "r");
• fopenr("c:\\test\\time.txt" , "r");
2. The logical operator OR is similar to:
Answers:
• !=
• ||
• &&
• !==
3. How do you add a multi-line comment in PHP?
Answers:
• *\ This is a comment \*
• <!-- This is a comment -->
• <comment> This is a comment </comment>
• /* This is a comment */
4. If a string is enclosed in double-quotes, PHP will interpret more escape sequences for special characters such as
Answers:
• \n
• \r
• All of these
• \"
5. How do you write "Hello World" in PHP
Answers:
• echo "Hello World";
• document.print("Hello World");
• out << "Hello World";
• "Hello World";
6. What is the correct way to create a function in PHP?
Answers:
• function myFunction(){ echo "Example function.\n";};
• new_function myFunction(){ echo "Example function.\n";};
• create myFunction(){ echo "Example function.\n";};
• createFunction myFunction(){ echo "Example function.\n";};
7. Which of the following variables is not a predefined variable?
Answers:
• $ask
• $request
• $get
• $post
8. What does the acronym LAMP stand for?
Answers:
• Linux Apache MySQL PHP (or Perl/Python)
• Linux And MySQL PHP
• Linux Apache Monitoring Program
• Linux Application in MySQL PHP
9. What is the output from this example? $str = "My name is O\'Connor."; echo stripslashes($str);
Answers:
• My name is O\'Connor.
• None of these
• My name is O'Connor.
• My name is OConnor.
10. Which datatypes are treaded as arrays?
Answers:
• integer
• strings
• double
• float
11. In PHP the error control operator is _______
Answers:
• @
• !
• *
• &
12. <?php $array1=  array(“fast”, "faster”); $array1[0] = “faster”; if ($array1[1] == “faster”) {     $array1[1]= “fastest”; }  foreach($array1 as $output) {      echo $output . " "; } ?>
Answers:
• faster faster
• fastest faster
• faster fastest
• fastest fastest
• none of these
13. What is the result of the following code: $array[]="value";
Answers:
• adds new element at the end of the array
• is illegal, will throw an fatal error
• creates new array of chars from the given string
• adds new element to the array with null as a key
14. In PHP, the die() and exit() language constructs perform the same function.
Answers:
• False: They are not part of the PHP language
• True
• False: They produce different return codes
• False: They are actually MySQL functions
15. Which character is used to separate namespaces in PHP?
Answers:
• Arrow(->)
• Double colon (::)
• Backslash (\)
• Period(.)
16. What is the correct way to assign a class constant?
Answers:
• constant MY_CONSTANT = 'value';
• const $myConstant = 'value';
• private MY_CONST = 'value';
• const MY_CONSTANT = 'value';
17. Which function can be used to simplify searches in databases where you know the pronunciation but not the spelling
Answers:
• explode
• soundex
• parse_str
• preg_search
• strtolower
18. What is the default timeout of a PHP session cookie ?
Answers:
• 15 minutes
• 30 minutes
• Until the browser is closed
• Depends on the client browser
• Never
19. What is the result of the following code ? <?php     $a = 1;     echo $a++;     $a *= 2;     echo ++$a; ?>
Answers:
• 14
• 24
• 11
• 15
• 25
20. What is the result of the following code : <?php echo (strpos('abcdef', 'a')) ? : -1; ?>
Answers:
• -1
• true
• Syntax error
• 0
• 1
21. Which function is used to read an entire file into an array ?
Answers:
• fwrite
• file_to_array
• fgets
• file_get_contents
• file
22. What does this code do?  namespace Hello\World;
Answers:
• It creates two namespaces : "Hello" and "Hello\World"
• It creates two namespaces : "Hello\World" and "World"
• It creates two namespaces : "Hello" and "World"
• It creates one namespace : "World"
• It creates one namespace : "Hello\World"
23. In PHP, variables always start with which symbol?
Answers:
• !
• &
• %
• $
• #
24. Which of the following is not a valid PHP variable declaration?
Answers:
• $aVaR
• ${“MyVar”}
• $_10
• $10_var
25. The PHP function which capitalizes the first letter of each word in a string
Answers:
• strtoupper()
• caps()
• ucwords()
• ucfirst()
26. PHP's echo and print functions are not exactly alike. Which will accept multiple parameters and concatenate them in its "without parentheses" form?
Answers:
• echo
• both echo and print
• print
• neither echo nor print
27. What does the use of the final keyword in a method declaration prevent?
Answers:
• Child classes from overriding the method.
• All of these
• Specific properties within a class from being modified.
• Objects from being modified.
28. Which of the following statements is NOT true for PHP constants?
Answers:
• They are case sensitive.
• A valid constant name starts with a letter or an underscore.
• The scope of a constant is local.
• Their value cannot change for the duration of the script.
29. Which PHP function will return a file's last access time?
Answers:
• filectime()
• fileatime()
• fileaccesstime()
• file_access_time()
30. What is default session time in PHP?
Answers:
• infinity
• 1440 seconds or 24 minutes.
• 1800 seconds or 30 minutes.
• 3600 seconds or 60 minutes.
• 900 seconds or 15 minutes.
31. Which of those is not magic method?
Answers:
• __callStatic
• __sleep
• __toInt
• __toString
• __clone
32. What is the recommendation regarding PHP closing tags in a document?
Answers:
• Only use the closing tag when short tags are enabled.
• Omit the closing tag when the file contains only PHP code.
• End all PHP files with '?>'.
• There is no recommendation.
33. What is PHAR?
Answers:
• The PHP way to distribute entire applications within a single file ("PHP Archive")
• The PHP official application and extensions repository ("PHP Application Repository")
• The PHP official reference on advanced topics ("PHP Advanced Reference")
34. Which of the following will return TRUE?
Answers:
• is_null(3.14)
• is_numeric(M_PI)
• is_numeric("three point one four")
• is_string(M_PI)
35. What is the primary difference between interfaces and abstract classes in PHP?
Answers:
• Abstract classes cannot have function implementations.
• Interfaces can contain variables,
• Multiple Inheritance is available for an Abstract class.
• Interfaces cannot have function implementations.
36. Which character is used to separate namespaces in PHP?
Answers:
• Double colon (::)
• Backslash (\)
• Period(.)
• Arrow(->)
37. What does this output? $pos = strpos('Atlanta', 'a'); echo $pos;
Answers:
• 3
• 4
• 0
• 7
• 1
38. If one wants to convert all double quotes (") to a backslash followed by a double quote (\") which of the following can be used?
Answers:
• addbackslash()
• htmlspecialchars()
• escape_quotes()
• None of these
• addslashes()
39. What function creates a cookie?
Answers:
• cookie()
• set_cookie()
• setcookie()
• establishcookie()
• create_cookie()
40. Which PHP functions generate random numbers following algorithms known as Mersenne Twister?
Answers:
• mt_alg() and mt_salg()
• mt() and smt()
• mt_rand() and mt_srand()
• rand() and srand()
41. Which statement will NOT combine strings $s1 and $s2 into a single string?
Answers:
• implode(' ',array($s1,$s2))
• $s1.$s2
• $s1 + $s2
• "{$s1} {$s2}"
42. The following code does what? <?php $textfile = "my_file.txt"; $file = fopen("$textfile", 'r+');  ?>
Answers:
• opens the file, “my_file.txt” for reading and writing
• opens the file, "my_file.txt" for reading only
• reads the entire file, "my_file.txt" into an array
43. How to capture exception message of a try / catch? Note: consider Exception $e
Answers:
• $e->getMessage();
• $e->getException();
• $e->getErrors();
• $e->getExceptions();
• $e->error();
44. What is the way to use the magic method '__toString()' of this Class ?  class exampleClass {     protected $a= 1;          protected $b= 2;        function __toString() {               return 'a= '. $this->a . ',b= '. $this->b;         } }
Answers:
• $c = new exampleClass(); strval($c);
• $c = new exampleClass(); (string) $c;
• All of the these.
• $c = new exampleClass(); $c->__toString();
45. What is the result of casting the integer 1 to an array: (array) 1
Answers:
• An associative array with a key of 1 and a value of 1
• A numerically indexed array with one element who's value is 1
• An associative array with a key of 1 and a value of NULL
• Casting an integer to an array has no effect
46. What do anonymous functions do in PHP?
Answers:
• allow the creation of global functions
• provide functions which run at the end of a script's execution
• None of these
• allow the creation of functions with no name
47. What function sets the default timezone used by all date and time functions in a script?
Answers:
• default_timezone_set('Region');
• date_set('Region');
• date_default_set('Region');
• date_default_timezone_set('Region');
• timezone_set('Region');
48. What is one of the difference between the use of single quotes and double quotes in PHP syntax?
Answers:
• variable names will be expanded in double quotes
• variables names will not be expanded in double quotes
• double quoted strings cannot contain line breaks
• single quoted strings cannot contain line breaks
49. Which of the following string delimiting methods is known as the heredoc syntax?
Answers:
• delimited by double quote
• All of above
• delimited by single quote
• delimited by <<< identifier
50. $table = array("old_value");  foreach($table as $row) {          $row="new_value"; } echo $table[0];  will produce:
Answers:
• Fatal error, as the variable used in foreach is read-only
• "old_value"
• "new_value"
51. Which PHP function closes an open SQLite database?
Answers:
• SQLite3Stmt::close();
• All of these
• sqlite_close($dbhandle);
• close();
52. Which function sorts an array in descending order?
Answers:
• sort()
• rsort()
• usort()
• ksort()
53. What does the following code: $array[]="value";
Answers:
• adds new element at the end of the array
• creates new array of chars from the given string
• is illegal, will throw an fatal error
• adds new element to the array with null as a key
54. Choose the string for which the POSIX regular expression ^[A-Za-z]$ matches.
Answers:
• 67
• 2I
• P
• &
55. Which of the following functions allows you to split a string by a regular expression and put the results into an array?
Answers:
• preg_split()
• explode()
• join()
• implode()
56. Given the following code, the Atom class can access which variables?  class Flash { public $fast; private $superSpeed; private $ultraSonic;  protected $warp; }  class Atom extends Flash { }
Answers:
• $fast, $superSpeed, $ultraSonic
• $superSpeed, $ultraSonic
• $fast
• $fast, $superSpeed, $ultraSonic, $warp
• $fast, $warp
57. Given the statement,  mysqli_connect(“happy.com”, “hot24”, “015A#”, “ABC”);  “happy.com” and “hot24” respectively refer to ?
Answers:
• Host, database
• Host, username
• Server, client
• Password, username
• Database, host
58. What's the MIME type for images with correct extension "jpg"?
Answers:
• mime/.jpg
• mime/jpg
• image/jpg
• jpg
• image/jpeg
59. What is default session time in PHP ?
Answers:
• 3036 Seconds
• 1436 Seconds
• 1440 Seconds
• 2000 Seconds
60. The PHP instruction header("Content-Type: text/plain") should be sent:
Answers:
• after the page is loaded.
• in the HTML header.
• before any output is sent
• inside of a function.
61. Which of the following will this function output: <? $father="mother"; $mother="son"; echo $$father; ?>
Answers:
• son
• mother
• error
• father
62. The only code construct allowed before a namespace declaration is the declare statement, for defining encoding of a source file
Answers:
• false
• true
63. What is the default execution time for a PHP script?
Answers:
• 10 secs
• 20 secs
• 60 secs
• 30 secs
64. What will be the result of the following:  echo ucwords(strtoupper('aAaA bBbB'));
Answers:
• aaaa bbbb
• Aaaa Bbbb
• aAAA bBBB
• aAaA bBbB
• AAAA BBBB
65. Which compound type is supported by PHP?
Answers:
• float
• array
• boolean
• integer
66. Which of the following functions would allow you to convert a string to an array?
Answers:
• implode()
• explode()
• st2arr()
• expand()
• to_array()
67. How do you create a non-public method, which can be used in a child-class?
Answers:
• private function Something() {
• parent function Something() {
• protected function Something() {
• nonpublic function Something() {
• preserved function Something() {
68. How would you delete a cookie?
Answers:
• set the expiration date in the past
• use session_destroy()
• eat it warmed with milk
• do not set an expiration
• use cookie_destroy()
69. What will range('a', 'z') return?
Answers:
• This function call will throw an exception
• False
• An alphabetically ordered array of letters from 'a' to 'z'
• Distance between letters 'a' and 'z' on an alphabetically ordered list
70. Which one removes a cookie from client's browser?
Answers:
• setcookie('mycookie', '', time()-3600);
• deletecookie($_COOKIE['mycookie']);
• unsetcookie('mycookie', 0, 1);
• removecookie('mycookie', 0, time()-3600);
71. Which one removes a cookie from client's browser?
Answers:
• setcookie('mycookie', '', time()-3600);
• deletecookie($_COOKIE['mycookie']);
• unsetcookie('mycookie', 0, 1);
• removecookie('mycookie', 0, time()-3600);
72. What variable scope would you use if you wanted a function variable which does not discard it's value when the function has completed execution?
Answers:
• local
• None of these
• function parameter
• static
73. Error reporting constants are used to adjust error reporting settings.  Which of the following is NOT a valid error reporting constant?
Answers:
• E_CONSTANT
• E_STRICT
• E_NOTICE
• E_WARNING
• E_ALL
74. function foo($bar) {   if($bar['soap'] != 'Zest') {     return $bar['soap'];   } }  Which best describes the function foo()?
Answers:
• It is syntactically incorrect
• It will return an error
• It is an anonymous function
• The parameter(s) passed to it is/are an associative array
• It opens an infinite loop
75. What is the value of $res in the following script? <?php $str = "1"; $int = 1; $res = ($str === $int); ?>
Answers:
• False, because the variables $str and $int are not of the same type.
• False, because a type conversion cannot be performed between int and string.
• True, because the === operator only performs a value comparison.
• True, because "1" is equal to 1 after a type conversion.
76. The following would return?  extract(   array(     'sexy' => 'a',     'and' => 'b',      'i' => 'c',      'know' => 'd',      'it' => 'e'   ) );  return $sexy.$and.$i.$know.$it;
Answers:
• false
• sexyandiknowit
• Notice: Undefined variable
• true
• abcde
77. $val = "";  What will isset($val) return?
Answers:
• 0
• false
• true
78. What will be displayed?  <?php $var = "6"; var_dump($var); $var++; var_dump($var); ?>
Answers:
• int(7)
• string(1) "6"
• string(1) "6" int(7)
• string(1) int(7)
79. Which function returns the contents of the output buffer and empties the buffer?
Answers:
• ob_ret_clean();
• ob_get_clean();
• ob_own_clean();
• ob_return_clean();
80. echo substr("Hello world",-4); the right output is?
Answers:
• orld
• hello
• world
• hell
81. In this example code, $result = print_r ($a); $result is the
Answers:
• property.
• argument.
• expression.
• variable.
82. Which type of array allows you to use textual keys so that array indices can be more descriptive?
Answers:
• Textual
• Key
• All of these
• Associative
83. Self-contained collections of functions AND properties are referred to as
Answers:
• elements.
• references.
• objects.
• collections.
84. The interpreter executes one PHP command which ends in a semi-colon.  This is referred to as a
Answers:
• All of these
• PHP function.
• PHP statement.
• PHP array.
85. natsort( array( "i10", "i1", "i20" ) ) = ?
Answers:
• array( "i1", "i10", "i20" )
• array( "i20", "i10", "i1" )
• array( "i10", "i1", "i20" )
• array( "i10", "i20", "i1" )
• false
86. Which of the following is the scope resolution operator in PHP?
Answers:
• .=
• ->
• ::
• All of these
• &
87. The break statement ends execution of which of the following structures?
Answers:
• switch
• while
• for
• All of these
88. What is meaning of PEAR?
Answers:
• PHP Execution and Application Repository
• PHP Extension and Application Register
• PHP Extension and Application Repository
89. What is the value of $start after exiting the for loop? <?php  $start=5;  for ($i=0; $i !=1; $i++) {    $start= $start - 2;  } ?>
Answers:
• 1
• 5
• 2
• 4
• 3
90. The following code will produce: var_dump(5 === "5");
Answers:
• bool(true)
• string(1) "5"
• bool(false)
• int(5)
91. <?php $array1=  array(“fast”, "faster”); $array1[0] = “faster”; if ($array1[1] == “faster”) {     $array1[1]= “fastest”; }  foreach($array1 as $output) {      echo $output; } ?>
Answers:
• faster faster
• none of these
• fastest fastest
• fastest faster
• faster fastest
92. Choose the variable assignment which is performed 'by value' in PHP.
Answers:
• $value1= %$value
• $value1= $value
• None of these
• $value1= &$value
93. Which of the following is not a valid key type for arrays in PHP?
Answers:
• strings
• All of these
• objects
• integers
94. The web server sets a cookie on the web client by sending the name/value pair as part of
Answers:
• java protocol.
• a database object.
• a session.
• an HTTP header.
95. The case expression is used as part of a PHP ____.
Answers:
• switch statement.
• try / catch condition.
• All of these
• if statement.
96. What separates a sequence of one or more characters used to specify the boundary between separate text regions?
Answers:
• parser
• delimiter
• separater
• extended value
97. Which PHP function sends a raw HTTP header to a client?
Answers:
• header()
• raw()
• $_REQUEST
• $_HTTP
98. You can call a parent class' implementation of a method which is overridden by a child class using:
Answers:
• parent::
• This is not possible
• $this->
• above::
• self::
99. Which  variable assignment is 'by reference' in PHP?
Answers:
• All of these
• $value1= $value;
• $value1= &$value;
• $value1= % $value;
100. To suppress error messages to the user, preface the PHP statement with
Answers:
• @
• %
• !

• #
101. Which PHP function returns "true" if a value already exists in an array?
Answers:
• array_search()
• array_key_exists()
• array_found()
• in_array()
• is_array()
102. True or False: There is no difference in using the following 2 examples:  echo('string'); echo 'string';
Answers:
• True
• False
• It depends on the server environment
103. What does the following output? echo (5 % 3);
Answers:
• 2
• 1
• None of these
• 15
104. How do I typecast a variable to boolean?
Answers:
• Both are valid statements.
• $var = (bool)$var;
• It's not possible to typecast variables like this.
• $var = ($var == $var);
105. Which rule determines which sections of script are able to access which variables?
Answers:
• Functions
• Variable Scope
• Arrays
• Parameters
106. What is the scope of a PHP constant?
Answers:
• local
• None of these
• global
• variable
107. Which variable name is incorrect?
Answers:
• $_1FIRST
• $1first
• None of the above.
• $first
108. How would you create a numeric array from the following string that did not include "-test" and where each digit had its own array key?  $str = '6.1.4.2.6-test';
Answers:
• $arr = explode('-', $str); $arr = explode('.', $arr[0]);
• You can't
• $arr = str_replace('-', '', $str);
• $arr = implode('-', $str); $arr = implode('.', $arr[0]);
109. The comparison $a <> $b means
Answers:
• $a is less than $b
• $a is greater than or less than $b
• $a is not equal to $b
• $a is equal to $b
110. Choose the output of the following script. <?php $rest = substr("abcdef", -1); echo $rest; ?>
Answers:
• e
• a
• f
• 0
111. Which PHP function checks to see if a file exists and is writable?
Answers:
• isset()
• if_exists()
• write()
• is_writable()
112. What is the difference between the include() and require() language constructs?
Answers:
• They handle failure differently.
• There is no difference.
• They handle file paths differently.
• None of these.
113. Choose the correct output. <?php $data = "98.8degrees"; $data = (double)$data; echo $data; ?>
Answers:
• 98.8degrees
• degrees
• 98
• 98.8
114. Which of the following is the correct way to add comments to PHP?
Answers:
• // Comment code here
• /* Comment code here */
• # Comment code here
• All listed methods are valid
115. Which PHP function sorts an array and maintains index association?
Answers:
• awalk()
• sort()
• asort()
• array_alpha()
116. In this example code, $result = print_r($a); $a is the
Answers:
• property
• element
• argument
• function
117. Is $_SERVER['PHP_SELF'] subject to injection vulnerabilities?
Answers:
• No, it's safe. It can only contain paths and filenames specified by the web master.
• Yes, it's vulnerable. On most servers PATH_INFO is supported, which is part of PHP_SELF
118. What is a collection of characters that is treated as one entity called?
Answers:
• Element
• Function
• Parameters
• String
119. The PHP mail() function allows you to...
Answers:
• send mail messages directly from a script.
• None of these
• send a mail message according to the IMAP protocol directly from a script.
• send a mail message according to the POP3 protocol directy from a script.
120. Which PHP function or variable will return the value of current session id?
Answers:
• $_SESSION['CURRENT_ID']
• $_SESSION['ID']
• session_id()
• curr_session_id()
121. Variables in PHP are represented by a dollar sign followed by the name of the variable. A valid name must NEVER start with a...
Answers:
• Any of these.
• letter.
• number.
• underscore.
122. Which function advances the internal array pointer of an array?
Answers:
• current()
• next()
• move()
• skip()
123. Which of the following is valid PHP syntax?
Answers:
• if($a == 5) echo "a = 5";
• if($a == 5) then echo "a = 5"; endif
• None of these
• if($a == 5) echo "a = 5"; endif
124. What is the GD Library?
Answers:
• It is a library that gives the PHP the capability to create and manipulate image files. - (Gif Draw)
• It is a library that gives the PHP the capability to access and create virtual domains. - (Generated Domain)
• it's add a dozen of special new $_GLOBAL variables that gives principally informations on the user (localization, common social media cookies, etc...) - (Global iDentification)
125. Which of the following is false?
Answers:
• PHP can be deployed on most web servers.
• PHP applications must be compiled.
• PHP can be used to develop web applications.
• PHP code is embedded into HTML source code.
126. Which of the following outputs a formatted string?
Answers:
• printf("Hello %s", $name);
• print("Hello %s", $name);
• output("Hello %s", $name);
• echo("Hello %s", $name);
127. OCI8, PostgreSQL, and SQLSRV are all examples of
Answers:
• All of these
• queries available in PHP.
• form extensions available in PHP
• database extensions available in PHP.
128. Which statement is true regarding the XML support in PHP?
Answers:
• All of these
• XML validation is not provided
• the PHP XML extension implements xpath
• XML parsing is provided
129. Which function sets the internal pointer of an array back to its first element?
Answers:
• next()
• loop()
• current()
• reset()
130. Which of the following language constructs is used to terminate a running script?
Answers:
• kill()
• exit()
• break()
• eval()
• halt()
131. What is output by the following: $c = 1; ++$c; echo $c++;
Answers:
• 1
• 2
• 4
• 3
132. Which statement would produce the output,  "I love summer"?
Answers:
• All of these
• <?="I love summer"?>
• <?php $message="I love summer"; echo $message; ?>
• <?php $season="summer"; echo "I love $season" ; ?>
• <?php print ("I love summer"); ?>
133. What does this function do: function my_func($variable) {     return (is_numeric($variable) && $variable % 2 == 0); }
Answers:
• Tests whether $variable is an even number
• Tests whether $variable is a number and contains 2
• Tests whether $variable ends in 2
• Tests whether $variable is a number and ends in 2
134. Which PHP function will combine two arrays?
Answers:
• array_merge()
• array_combine()
• array_sum()
• array_push()
135. What function can be used to help prevent MySQL injection?
Answers:
• None of the above
• mysqlescapethisstring()
• mysql_real_escape_string()
• mysql_escape()
• escape_mysql_string()
136. Which function allows you to delete a file?
Answers:
• remove
• delete
• clearfile
• unlink
137. Which of the following functions changes directory on ftp-connection?
Answers:
• ftp_chmod()
• ftp_login()
• ftp_mkdir()
• ftp_chdir()
• ftp_connect()
138. What is a large binary data object called in PHP?
Answers:
• blurb
• bin
• blob
• lib
139. In PHP, you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings.
Answers:
• False
• True, but double quotes will expand PHP variables and escape sequences inside it.
• True, they are the same thing.
140. Which PHP function creates an array by using one array for keys and another for its values?
Answers:
• array2()
• $array()
• array_combine()
• combine()
141. Choose the word(s) that describe the fundamental style of programming for PHP.
Answers:
• All of these
• imperative
• object-oriented
• procedural
142. What type of statements tell your PHP script to execute a section of code only if certain criteria are met?
Answers:
• Conditional
• Class
• Exception
• Function
143. What does the acronym LAMP stand for?
Answers:
• Linux Apache Monitoring Program
• Linux Apache MySQL PHP/Perl/Python
• Linux And MySQL PHP
• Linux Application in MySQL PHP
144. Which keyword causes a conditional loop to skip to the start of the next iteration?
Answers:
• continue
• end
• begin
• return
145. Which function removes all HTML and PHP tags?
Answers:
• strip_tags()
• remove_html_php()
• tag_remove()
• remove_tags()
146. Which of the following is the recommended standard (short_opentag=Off) for opening and closing a PHP code block?
Answers:
• '<?' to open and '?>' to close
• '<!php' to open and '!>' to close
• '<%php' to open and '%>' to close
• '</=' to open and '/>' to close
• '<?php' to open and '?>' to close
147. What type of operator is && in PHP?
Answers:
• comparison operator
• assignment operator
• arithmetic operator
• logical operator
148. What does the following PHP statement create? define("FIRST-NAME","John");
Answers:
• a definition
• a variable
• special characters
• a constant
149. How can we increase the execution time of a PHP script from setting php.ini?
Answers:
• By setting max_script_execution_time
• By setting script_execution_time
• By setting max_execution_time
• By setting max_script_time
150. What will it output? <?php $var = "pontus, patrik, felix"; $var = explode(", ", $var); echo count($var); ?>
Answers:
• A error message.
• 3
• 4
• 1
• 2
151. Which function converts a string to all uppercase characters?
Answers:
• upper()
• strtoupper()
• uppercase()
• ucase()
152. Which PHP extension provides an abstract method for database retrieval?
Answers:
• POP
• TRC
• PDO
• STMP
153. True or False? Arrays in PHP can only hold the same data type.
Answers:
• False
• True
154. What is output to the screen when executing code: $> php -r 'echo echo "a";'
Answers:
• PHP Parse error
• a
• aa
• truea
155. What is the output? <?php $boolean= true; while ($boolean) {   $boolean =false; echo "false"; }
Answers:
• syntax error
• None of the these
• true
• falsefalse
• false
156. What are the default header request protocols defined in PHP?
Answers:
• XML
• application
• All of these
• XHTML
• HTML
157. Which following function is used to count total number of characters in a string?
Answers:
• count();
• total_chars();
• num_chars();
• strlen();
• str_count();
158. Which PHP function returns an array with elements in reverse order?
Answers:
• None of these
• reverse()
• array_descend()
• array_reverse()
159. HTTP cookies can be used to:
Answers:
• validate input fields.
• identify a user.
• check for SQL injections.
• create client side scripts.
160. A fatal run-time error would be caught by
Answers:
• E_NOTICE
• E_WARNING
• ERROR
• E_ERROR
161. What PHP function counts elements in an array, or properties in an object?
Answers:
• count()
• array_count()
• add()
• digits()
162. Which of the following displays the browser properties using PHP?
Answers:
• $_SERVER['BROWSER_DETAIL']
• $_SERVER['BROWSER_NAME']
• $_SERVER['HTTP_USER_AGENT']
• $_SERVER['HTTP_AGENT']
163. Which function checks for the existence of a particular key?
Answers:
• array_key_exists()
• element()
• for_each()
• isset()
164. Which is an example of a statement using a combined operator?
Answers:
• $a += $b
• $a != $b
• $a == $b
• $a--
• $a++
165. The setcookie() function must appear _____ the <html> tag.
Answers:
• after
• before
166. If you would like to check to see if a PHP variable has data, which of the following language constructs would you use?
Answers:
• none().
• null().
• empty().
• data().
167. What is the output from this example? $str = "My name is O\'Connor."; echo stripslashes($str);
Answers:
• My name is O'Connor.
• My name is OConnor.
• None of these
• My name is O\'Connor.
168. An array in PHP is an ordered map which associates
Answers:
• elements to attributes.
• keys to values.
• values to pairs.
• None of these
169. What function converts 'Hatfields & McCoys' into 'Hatfields &amp; McCoys'?
Answers:
• ampersand()
• convert()
• transform()
• htmlentities()
170. Which of the following is NOT a function of PHP session support?
Answers:
• session_destroy
• session_pw
• session_id
• session_decode
171. Which type is not supported by PHP?
Answers:
• string
• integer
• time
• boolean
• array
172. The PHP operator, %, which returns the remainder of an equation is called the:
Answers:
• pre-increment
• modulus
• remainder
• floating integer
173. Include files can have which file extensions?
Answers:
• Any of these
• .txt
• .inc
• .php
174. PHP requires instructions to be terminated at the end of each statement with a
Answers:
• </php>
• ?>
• }
• ;
175. Which of the following statement best describes:  $panther = new Animal();
Answers:
• Declaration of a string
• Access modifier
• Invocation of a function
• Instantiation of an object
• Constructor
176. Which PHP math function would you use to round  a number upwards to the nearest integer?
Answers:
• max()
• ceil()
• top()
• up()
177. What function is used to check if a variable is an array?
Answers:
• array_exists()
• in_array()
• array_check()
• array()
• is_array()
178. What will be the result of this code:  <?php $text1 = "Test"; $text2 = "Test"; if($text1 == md5($text2)) { echo "Yes"; } else { echo "No"; }
Answers:
• Yes
• No
• PHP ERROR
179. What is the output of flowing code? <?php $cars=array("Volvo","BMW","Toyota"); sort($cars);  $clength=count($cars); for($x=0;$x<$clength;$x++)    {    echo $cars[$x];    echo " ";    } ?>
Answers:
• Volvo BMW Toyota
• BMW Toyota Volvo
• Volvo Toyota BMW
180. What will this return: $value="Hello_World"; $rt=explode("_",$value); echo $rt[0];
Answers:
• World
• HelloWorld
• Hello
• WorldHello
181. How do you perform a strict comparison of variables for type and value?
Answers:
• None of these
• $a == $b
• $a === $b
• $a = $b
182. Which statement is true about PHP constants?
Answers:
• They are case-sensitive by default.
• They cannot contain an array.
• They cannot be changed.
• All of these.
183. Which statement correctly declares a float variable in PHP?
Answers:
• $a = 4.5e3;
• All of these
• $a = 1.234;
• $a = 7E-10;
184. Which function allows you to split a string into an array of substrings by a string delimiter?
Answers:
• split("", string)
• explode(" ", $str)
• str(" ", $str)
• None of these
185. When using the POST method, variables are displayed in the URL:
Answers:
• Only when posted by a form
• False
• Only when posted with AJAX
• True
186. What is the result of the following code? <?php $hello ="HELLO"; $hello=lcfirst($hello); echo $hello; ?>
Answers:
• hello
• HELLO
• hELLO
• None of these
• hellO
187. True or false? We can include ("sandy.php") two times in one PHP page "my.php".
Answers:
• False
• True
188. mysqli_num_rows() function is used to:
Answers:
• Count number of columns in MySql Table.
• Get all rows contain numbers.
• Get all columns with numeric data.
• Count number of characters in single row of MySql Query result.
• Count number of rows in result of MySql Query.
189. What is the value of $var when the following line is executed in a PHP function? unset($var);
Answers:
• " "
• Neither of these.
• NULL
190. What is the right way to set a value on an object stdClass?
Answers:
• $variable->value = 'value';
• $variable['value'] = 'value';
• $variable.['value'] = 'value';
• $variable.value = 'value';
• $variable[value] = 'value';
191. How do you specify a string literal in PHP?
Answers:
• 'Hello there'
• All of these
• <<<EOD Hello there EOD;
• "Hello there"
192. To output information about a variable use the function
Answers:
• var_dump()
• output()
• print_var()
• display_var()
193. An array in PHP is:
Answers:
• a collection of key value pairs.
• a data file.
• a series of variables.
• None of these
194. Which function returns one or more randomly selected keys from an array?
Answers:
• array_diff_key()
• array_rshuffle()
• array_rand()
• array_rchunk()
• array_rand_pop()
195. What does this statement do? <?php echo b"testing string"; ?>
Answers:
• It will convert the string into binary
• It won't do anything
• It will throw an error
196. Which function tests a string for an exact match of the argument?
Answers:
• str()
• regex()
• test()
• preg_match()
197. Which variable contains values of $_GET, $_POST, and $_COOKIE?
Answers:
• $_REQUEST
• $_ALL
• $_INCLUDE
• $_MERGE
198. Which PHP function would you use to display information about variables in a simple, readable format?
Answers:
• infp()
• display()
• dump()
• var_dump()
199. Which PHP function creates a directory on an FTP server?
Answers:
• ftp_mkdir()
• ftp_chdir()
• ftp_create_dir()
• ftp_make_dir()
200. Can PHP be run on a Windows IIS server?
Answers:
• Only if installed on a separate partition.
• true

• false
201. __construct is a
Answers:
• pseudo element for an object.
• class for the object.
• regex method for an object.
• constructor for an object.
202. Which function allows you to specify a start position of a string and length arguments to retrieve part of a string?
Answers:
• chunk_split()
• str()
• substr()
• parse_str()
203. Which PHP function randomizes the order of the elements in an array?
Answers:
• mix()
• shuffle()
• reverse()
• combine()
204. In PHP, which statement is used to retrieve browser properties?
Answers:
• $_SERVER['PHP_SELF']
• $_SERVER['HTTP_HOST']
• $_SERVER['HTTP_USER_AGENT'];
• $_SERVER['SERVER_NAME']
205. Which control statement indicates a block of code to be repeated a number of times?
Answers:
• switch
• for
• if
• include
206. Which of the following variables does PHP make automatically available to you?
Answers:
• $_DIR
• $_UPLOADED_FILES
• $_SERVER
207. Which of the following stores PHP values, such as  strings, numbers or arrays?
Answers:
• attributes
• ID's
• variables
• classes
208. Which of the following is NOT used to specify PHP comments?
Answers:
• /* */
• <!-- -->
• //
• #
209. Given, the following: <?php $business = array("retail", "advertising", "computer"); echo current($business)."\n"; echo next($business)."\n"; echo $business[2]."\n"; ?> What is the output?
Answers:
• retail advertising computer
• retail computer computer
• retail retail retail
• retail retail computer
210. Which of the following returns information passed via HTTP forms?
Answers:
• $_POST
• $_GET
• $_REQUEST
• All of these
211. Select the type of  variable scope which is not supported by PHP:
Answers:
• Function parameters
• Local variables
• Global variables
• Hidden variables
212. Choose the correct value for $i. $i = 2; $i++;
Answers:
• 2
• 4
• 5
• 3
213. Which function returns information on the PHP configuration you are using?
Answers:
• phpAll();
• phpNotice();
• phpinfo();
• phpconfig();
• phpsearch();
214. Which PHP math function would you use to return the number with the lowest value of two specified numbers?
Answers:
• ceil()
• bottom()
• min()
• max()
215. What is the correct way to require the file "time.inc" in a manner which will halt the script upon failure?
Answers:
• <?php include_file("time.inc"); ?>
• <!--require file="time.inc"-->
• <% include file="time.inc" %>
• <?php require('time.inc'); ?>
216. Which of these does not represent a single, valid PHP variable
Answers:
• $myvar
• $my-Var
• $myVar
• $my_Var
217. PHP requires that instruction statements be terminated with a:
Answers:
• curly brackets
• semicolon
• period
• underscore
218. The practice of combining strings and variables into one string is called:
Answers:
• connecting
• joining
• concatenation
• combination
219. How to call a method from within a class?
Answers:
• $this( my_function() );
• private my_function();
• $this.my_function();
• public my_function();
• $this->my_function();
220. Which of the following checks if a value exists in an array?
Answers:
• in_array
• exists
• PHP does not provide any inbuilt way of doing this.
• exists_list
221. To modify the default PHP settings such as whether to accept the short form open tag (<?), you need to change the
Answers:
• htaccess file.
• php.inc file.
• php.ini file.
• machine.config file.
222. $var = (10 % 2 == 0) ? true:false;  What is the output of $var?
Answers:
• false
• true
223. How do you inherit the methods from BaseClass in MyClass?
Answers:
• class MyClass using BaseClass {
• class MyClass includes BaseClass {
• class MyClass parent BaseClass {
• class MyClass inherits BaseClass {
• class MyClass extends BaseClass {
224. How do you define a constant in PHP?
Answers:
• define("CONSTANT", "Hello world.");
• eval("CONSTANT", "Hello world.");
• constant("CONSTANT", "Hello world.");
• defined("CONSTANT", "Hello world.");
225. Which PHP function returns part of a string?
Answers:
• ctrl alt delete
• strpos()
• substr()
• All of these
226. Which of these assigns a value of type string to variable $x?
Answers:
• $x = true;
• $x[] = "true";
• $x = "true";
227. Which statement returns the number of characters in the string variable $a?
Answers:
• sizeof($a)
• chr($a)
• count($a)
• strlen($a)
• len($a)
228. What is meant by nl2br()?
Answers:
• Inserts HTML line breaks (<BR />) before all newlines in a string.
• Inserts HTML line breaks (<NL/>) before all newlines in a string.
• Inserts HTML line breaks (<HR />) before all newlines in a string.
• Inserts HTML line breaks (<P />) before all newlines in a string.
229. Which PHP math function would you use to generate a random integer?
Answers:
• rand()
• next()
• int()
• random()
230. Which PHP function would you use to display the  value of an array in a readable format?
Answers:
• display()
• return()
• print_r()
• print()
231. Include files must have the file extension ".inc"
Answers:
• True
• False
232. The FTP functions can be used to perform the following actions on file servers:
Answers:
• Open a connection
• None of these.
• All of these
• Upload files
• Login to a connection
233. Which of the following are examples of PHP comments?
Answers:
• //
• /* */
• All of these
• None of these
234. Which function gives you the current PHP version information?
Answers:
• phpcredits()
• phpversion()
• version_compare()
• version()
235. Which statements start a session and end a session?
Answers:
• session_start(); session_destroy();
• begin_session(); end_session();
• session_start(); unset_session();
• start_session(); end_session();
• start_session(); session_explode();
236. The concatenation operator in PHP is
Answers:
• .
• +
• ->
237. Which of the following is NOT a command for sending output to the standard output?
Answers:
• printf
• print
• send
• echo
238. Which construct is typically used for exception handling in PHP?
Answers:
• session();
• E_STRICT
• modify()
• try / catch
239. Which PHP function finds the position of the last occurrence of a substring within a string?
Answers:
• pos()
• split()
• strrpos()
• haystack()
240. What do you need to call in order for your session variables to work?
Answers:
• ob_start()
• $_SESSION_BEGIN
• session()
• session_start()
• session_begin()
241. Which function can be used to convert 'ff' to 255?
Answers:
• octdec()
• bindec()
• dechex()
• hexdec()
242. Which PHP function opens a file for reading only?
Answers:
• open("c:\\test\\time.txt");
• fopen("c:\\test\\time.txt" , "r");
• fopen("c:\\test\\time.txt" , "w");
• fopenr("c:\\test\\time.txt" , "r");
243. In the following PHP script, $arr = array(1,2,3);,  1, 2, and 3 are the array
Answers:
• keys
• values
• subscript
• index
244. Which function is used to perform a regular expression match in PHP?
Answers:
• match()
• preg_match()
• parse()
• combine()
245. An example of a float in PHP is:
Answers:
• 7E-10
• 12.678
• 1.2E3
• All of these
246. What kind of error causes the termination of the script?
Answers:
• None of them
• Warnings
• Fatal Errors
• Notices
247. Which of the following PHP language constructs allows you to combine code from one file into another?
Answers:
• All of the these
• require_once()
• include()
• require()
248. Which of the following are PHP comparison operators?
Answers:
• ===
• !=
• All of these
• ==
249. What is the correct way to create a function in PHP?
Answers:
• createFunction myFunction(){ echo "Example function.\n";};
• new_function myFunction(){ echo "Example function.\n";};
• function myFunction(){ echo "Example function.\n";};
• create myFunction(){ echo "Example function.\n";};
250. In PHP in order to access MySQL database, use the:
Answers:
• mysqli_connect() function
• mysqlconnect() function
• mysql-connect() function
• sql_connect() function
251. Which PHP function do you call to begin a PHP session?
Answers:
• session_active();
• start_session();
• session_start();
• session();
• open_session();
252. Which PHP language construct sends output to a browser window?
Answers:
• echo
• output
• display
• return
253. Which of the following HTML form submission methods is suitable when you need to send large amounts of form data?
Answers:
• Post
• Get
• Send
• Email
254. How do you add a multi-line comment in PHP?
Answers:
• /* This is a comment */
• *\ This is a comment \*
• <comment> This is a comment </comment>
• <!-- This is a comment -->
255. Which of the following variables is expected to contain information about the user's browser?
Answers:
• $_SERVER['SERVER_NAME']
• $_SERVER['HTTP_USER_AGENT'];
• $_SERVER['HTTP_VARIANT']
• $_SERVER['PHP_SELF']
256. Which of the following is a string operator?
Answers:
• dot(.)
• minus(-)
• plus(+)
• decrement(--)
257. How is the following statement interpreted in PHP? $i = 1;
Answers:
• $i is being compared to 1
• $i is assigned a value of 1
• $i is assigned a value of "one"
• None of these
258. The PHP syntax is most similar to:
Answers:
• Cobra
• Perl and C
• ABAP
• PostScript
• ALGOL 58
259. HTML form input needs to be validated in order to avoid:
Answers:
• SQL Injections.
• hacking.
• database intrusions.
• All of these
260. The statement header('Location: http://www.somesite.com'); will
Answers:
• creates a hyperlink.
• redirects the browser to www.somesite.com.
• displays the IP address of somesite.com.
• displays the header of somesite.com.
261. Which statement allows you to add new records to a MySQL database table?
Answers:
• All of these
• INSERT INTO
• PUT INTO
• ADD INTO
262. Which is a characteristic of the PHP language?
Answers:
• All of these
• embedded into HTML
• open source
• scripting language
263. Which operator is used to concatenate strings in PHP?
Answers:
• ampersand (&)
• dot (.)
• plus (+)
• logical and (and)
264. Which PHP function completely destroys all data relevant to the session?
Answers:
• session_destroy();
• destroy();
• session_close();
• session_end();
265. Placing ++  in front of variable:
Answers:
• will print as a string
• will cause a syntax error
• preincrements the variable by one
• creates a fatal error
266. A string literal in PHP can be specified in the following way(s):
Answers:
• All of these
• "this is a string"
• 'this is a string'
• <<<EOT this is a string EOT;
267. Which of the following function libraries are supported in PHP?
Answers:
• JSON
• MySQL
• GD
• All of these
268. Which function creates a directory on the FTP server?
Answers:
• ftp_makekdir()
• ftp_mkdirectory()
• ftp_mkdir()
• ftp_makedirectory()
269. The logical operator OR is equivalent to:
Answers:
• !==
• ||
• &&
• !=
270. Which variable is not predefined by PHP?
Answers:
• $_GET
• $_POST
• $_FILES
• $_ASK
271. What PHP function calculates the sum of the values in an array?
Answers:
• array_pop()
• array_sum()
• array_add()
• array_math()
272. Can PHP scripts be embedded directly into XHTML documents?
Answers:
• Depends on the Operating System
• Yes
• No
273. An example of a PHP string is:
Answers:
• $a
• "test"
• 10
• &&
274. What should you do in advance, to get and set session variable
Answers:
• _session_start()
• session_start_func()
• session_start()
• sessionstart_func()
• sessionstart()
275. strpos() stands for
Answers:
• straight position.
• string position.
• string positive.
• strap OS.
276. If a string is enclosed in double-quotes, PHP will interpret more escape sequences for special characters such as
Answers:
• \n
• \r
• \"
• All of these
277. How do you combine multiple arrays  into one single PHP array?
Answers:
• array_compare()
• array_shift()
• array_pop()
• array_merge()
278. What does MVC stand for?
Answers:
• Many Variable Classes
• Model Variable Container
• Model View Controller
• Maximum Visitor Connections
279. What are int, float, string and boolean examples of in PHP?
Answers:
• integers
• classes
• data types
• pointers
280. Choose the statement which produces this output: This is an example.
Answers:
• <script language="php"> print "This is an example.";</script>
• <? "This is an example."; ?>
• <p="This is an example."; ?>
• <?php echo "This is an example."; ?>
281. How do you retrieve the value of a variable called "name" which has been passed from a submitted form?
Answers:
• $_GetParameter[];
• Request.Form;
• Request.QueryString;
• $_GET["name"];
282. CakePHP, Zend, and CodeIgniter are popular _________ used on many PHP servers.
Answers:
• unit testing packages
• cacheing tools
• image processing libraries
• development frameworks
• version control software
283. If the allow_url_fopen configuration setting is enabled, which of the following functions will be able to open remote urls?
Answers:
• require()
• require_once()
• All of these
• include()
284. In PHP, functions using global variables must declare the variables by using
Answers:
• the LOCAL keyword.
• the GLOBAL keyword.
• the STATIC keyword.
285. One way to output a string in PHP is:
Answers:
• output()
• echo()
• str()
• display()
286. What's the output?  $name = 'John'; echo 'Hi there '.$name;
Answers:
• Nothing. There is a syntax error
• Hi there John
• Hi there
287. Which function will generate random integers?
Answers:
• rand()
• search()
• find()
• rad2deg()
288. Which of the following is a valid PHP function modifier?
Answers:
• final
• public
• All of these
• private
289. Which PHP function sorts an array?
Answers:
• combine()
• array_walk()
• sort()
• array_alpha()
290. Variables in PHP start with a
Answers:
• dollar sign($)
• dot(.)
• underscore(_)
• ampersand(&)
291. What types of arrays are supported in PHP?
Answers:
• Numeric
• Multi-dimensional
• All of these
• Associative
292. In PHP, how would you determine if a variable is set?
Answers:
• unset()
• isinit()
• isset()
• combined()
293. Which variable is used to collect values of a form sent via the HTTP POST method?
Answers:
• POST
• $POST
• _POST_
• $_POST
294. Which is a valid loop method in PHP?
Answers:
• Do
• For
• While
• All of these
295. Which construct includes an external PHP file?
Answers:
• All of these
• require_once
• require
• include
296. How do you write "Hello World" in PHP
Answers:
• echo "Hello World";
• document.print("Hello World");
• out << "Hello World";
• print("Hello World");
297. Which function checks for a specific PHP data type?
Answers:
• All of these
• is_int()
• is_numeric()
• is_float()
298. PHP variables always begin with
Answers:
• a dollar sign($).
• a number.
• a letter.
• underscore(_).
299. Which function would you use to check for data type?
Answers:
• is_numeric()
• is_int()
• All of these
• is_float()
300. The function mysql_connect( ) takes following parameter(s):
Answers:
• server
• All of these
• password

• username
301. All variables in PHP start with which symbol?
Answers:
• @
• $
• !
• %
302. PHP supports which of the following features?
Answers:
• include files
• All of these
• associative arrays
• mathematical functions
303. The PHP language can be used on the following operating systems:
Answers:
• Windows NT
• All of these
• Mac OS X
• Linux
304. Choose the output of the following code.  Assume that today is 2009-3-19:2:45:32 pm                              <?php $today = date("F j, Y"); ?>
Answers:
• Mar 19, 09
• March 19, 2009
• 03 19, 2009
• Mar 19, 2009
305. What function converts newlines to HTML line breaks in a string?
Answers:
• newlines()
• html_line_break()
• line_break()
• insert_br()
• nl2br()
306. Which PHP function can be used to generate a unique ID for members of your site?
Answers:
• uniqid()
• unpack()
• php_create_user()
• mt_random()
307. Which PHP string function is used to convert the first letter of a string to uppercase?
Answers:
• strUpperCase()
• strUpperFirst()
• ucfirst()
• strtoupper()
308. Which function displays a formatted string?
Answers:
• printf()
• print()
• echo
• dump()
309. After a file is successfully opened in PHP, how do you retrieve a line from the file?
Answers:
• fpointer
• fgets
• !feof
• line_number
310. What is the result of the following code? <?php $test =array("five", "six", 3, 4);  $hold= count($test); echo $test;  ?>
Answers:
• 2
• 3
• 0
• Array
311. Which PHP function tells whether a file exists and is readable?
Answers:
• is_readable()
• read()
• if_exists()
• isset()
312. In the date() function what does the 'm' format character do?
Answers:
• Insert month as Jan through Dec
• Insert month as 01 through 12
• Insert minute as 00 through 59
• Insert minute as 0 through 59
313. What is returned by array_product( array( 2, 3) )?
Answers:
• array( 2 )
• 3
• 6
• array( array( 2 ) )
• 2
314. dirname(__FILE__) will return what?
Answers:
• the current directory
• The directory in which the currently invoked file is located
• the same thing as $_SERVER['DOCUMENT_ROOT']
• The URL of the file it's placed in
• The relative location of the server root
315. Which is a valid character for starting a PHP function name?
Answers:
• All of these
• percent(%)
• dollar sign($)
• underscore(_)
316. Which PHP function removes the last value of an array and returns it?
Answers:
• array_unshift()
• array_last()
• array_shift()
• array_pop()
317. The PHP statement: $i[2] = "orange";  is an example of
Answers:
• a distributive array.
• an associative array.
• None of these
• a numeric array.
318. What does the return code E_ERROR indicate?
Answers:
• User-generated error message
• Compile-time parse error
• Run-time notice
• Fatal run-time error
319. Which function exchanges all keys with their associated values in an array?
Answers:
• array_compare(array)
• array_combine(array)
• array_flip(array)
• array_reverse(array)
320. Which type of control structure should NOT be used to check for a condition being met?
Answers:
• try / catch
• if /else
• switch
• None of these
321. To access functions of an instantiated class, you use the following:
Answers:
• class->function()
• class.function()
• class::function
• $class->function()
• $class::function()
322. In PHP, the die() and exit() language constructs perform the same function.
Answers:
• Time's Up!
• False: They are not part of the PHP language
• True
• False: They are actually MySQL functions
• False: They produce different return codes
323. What will be the value of $result?  <?php $myArr = array(     'val1' => 1,     'val2' => array('val21' => 21, 'val22' => 22),     'val3' => 3 ); $result = array_key_exists('val22', $myArr); ?>
Answers:
• true
• an error
• " "
• false
324. What function can you use to create your own streams using the PHP stream wrappers and register them within PHP?
Answers:
• stream_wrapper_reg
• stream_wrapper_register
• wrapper_register
325. How can you call this function?  $greet = function($name) {     printf("Hello %s\r\n", $name); };
Answers:
• $greet('World');
• $greet $World;
• PHP does not support this syntax.
326. How can we set the default time zone using PHP?
Answers:
• default_timezone(timezone_identifier);
• timezone_set(timezone_identifier);
• date_default_timezone_set(timezone_identifier);
327. Which methods are available in PHP to read a remote file?
Answers:
• file_get_contents()
• All of these
• fopen()
• curl_exec()
328. Which PHP function checks to see if HTTP headers have been sent?
Answers:
• http_response_code()
• headers_sent()
• header()
• sent()
329. Which of the following would be accepted as an argument parameter in the following function:      function getEmotion(Emotion $emotion) { ... }
Answers:
• A class called Emotion
• A class called Happy, which extends Emotion
• A class called Sad, which implements an Emotion interface
• All of these
330. Choose the correct output for:    $x=array(2=>"mouse",7=>"keyboard"); $y=array_keys($x);  echo $y[1];
Answers:
• keyboard
• 2
• 7
• mouse
331. Upon completion of a file upload in PHP, the UPLOAD_ERR_OK error code is returned.  What does this indicate?
Answers:
• No file was uploaded.
• The uploaded file was only partially uploaded.
• Failed to write file to disk.
• The file uploaded with success.
332. Which function opens an SQLite database and creates the database if it does not exist?
Answers:
• sqlite_open()
• sqlite_exec()
• sqlite_create()
• sqlite_current()
333. Which PHP function checks a month, day, and year number to determine if they form a valid Gregorian date?
Answers:
• checkdate()
• check_date()
• verify_date()
• verifydate()
334. print_r( 2 ) outputs:
Answers:
• 2
• Nothing, but returns false
• Throws an exception
• int(2)
• Array { [0] => 2 }
335. $a='1'; extract( array( 'a' => '2' ) ); echo $a;  outputs ...
Answers:
• 2
• Nothing
• 1
336. The function setcookie( ) is used to
Answers:
• enable or disable cookie support.
• send a cookie without url-encoding the cookie value.
• All of these.
• create, update, or delete a cookie header in the HTTP response
337. Which of the following functions can be used to execute a shell command?
Answers:
• passthru();
• system();
• All of these
• exec();
338. What is input sanitization?
Answers:
• Removing or cleaning potentially malicious user input.
• All of these
• The automatic process that creates the $_GET, and $_POST superglobals.
• Converting input into a format that PHP supports.
339. The function checkdate() returns what data type?
Answers:
• Boolean
• Timestamp
• Integer
• String
• Date
340. Which libraries are available for using regular expressions in PHP?
Answers:
• Neither of these.
• Perl-Compatible (PCRE)
• POSIX Regex
• Both of these.
341. To determine if the file pointer is at the end of a successfully opened file, use the...
Answers:
• feof() function.
• $end variable.
• $file_end variable.
• eof() function.
342. PHP scripts can be saved, and included later, under which allowed file extensions?
Answers:
• .inc and .php
• .php ONLY
• Any File Extension
• .inc, .common and .php
343. Variable $a has not been declared.  With error reporting turned off, what is the result of: $a[1][2]=3;?
Answers:
• A multi-level array structure is created with 3 as a value.
• Error: Undeclared variable $a
• Syntax error
• Error: Uninitialized array $a[1]
344. What is the correct way to assign a class constant?
Answers:
• private const MY_CONST = 'value';
• constant MY_CONSTANT = 'value';
• const MY_CONSTANT = 'value';
• const $myConstant = 'value';
345. $_SERVER, $_COOKIE, $_FILES, $_ENV are examples of PHP built-in variables called:
Answers:
• global arrays
• global functions
• $_GLOBALS
• superglobals
346. The comparison $a xor $b evaluates to...
Answers:
• FALSE if either $a or $b is TRUE, but not both.
• TRUE if either $a or $b is FALSE
• TRUE if either $a or $b is TRUE
• TRUE if either $a or $b is TRUE, but not both.
347. PHP variable $hello is set to “HELLO WORLD".  Which statement would return "Hello World" instead?
Answers:
• echo ucwords($hello);
• echo ucwords(strtolower($hello));
• echo ucfirst($hello);
• echo ucfirst(strtolower($hello));
348. Which of the following functions is used to format a number ?
Answers:
• format_num();
• format_number();
• num_format();
• format($number,$format_style);
• number_format();
349. Which of these is correct usage of the chmod() function?
Answers:
• chmod('/path/to/file', 0x755);
• chmod('/path/to/file', '-rwxr-xr-x');
• chmod('/path/to/file', 0755);
• chmod('/path/to/file', 755);
350. Which PHP function will return an array of values from $start to $end.
Answers:
• array_list( $start, $end);
• range( $start, $end);
• list( $start, $end);
• numbers( $start, $end);
351. Which statement opens a file for writing, to append data at the end of its content ?
Answers:
• fopen("myFile", "w")
• fopen("myFile", "a")
• fopen("myFile", "wa")
• fopen("myFile", "r+")
352. Which function removes the first element from an array, and returns the value of the removed element?
Answers:
• array_compare()
• array_shift()
• array_flip()
• array_pop()
353. Which of the following is true about the "touch" function in PHP?  Signature: touch($filename, $time) : boolean
Answers:
• $time is a required parameter of this function.
• If the file does not exist, it will be created.
• Modification timestamp is not modified, only access time (in the filesystem)
354. In PHP5, your "construct" method must be named the exact same thing as your "class".
Answers:
• Only on Lighttpd
• True
• Only on Nginx
• False
• When your class extends a parent class
355. When using php cli how can you return the same info as phpinfo()
Answers:
• php -I
• php -i
• php -c 'phpinfo();'
• php -a
356. How do single quotes interpret strings in PHP?
Answers:
• None of these
• literally except for variables which are expanded
• literally
• escape sequences are interpreted
357. class A{} class_alias( 'A', 'B' ); var_dump(new B);  outputs ...
Answers:
• NULL
• object(B)#1 (0) { }
• object(A)#1 (0) { }
• bool(false)
358. Which PHP function is used to replace a string?
Answers:
• substr_replace()
• str_replace()
• str_ireplace()
• All of these
359. What is the output of the following code? $one='two'; $two='one'; echo $$$one;
Answers:
• generates an error
• onetwo
• two
• one
• does not output anything
360. Which of the following functions does not have a resource for a return type?
Answers:
• strrpos()
• None of these
• mysql_connect()
• fopen()
361. What will the following code output: array_map("print_r", array( 'a', 'b' ) );
Answers:
• a
• Array{ [0] => 'a', [1] => 'b' }
• Nothing
• ab
362. What will be the output for the following code? $values = array(0, NULL, FALSE); foreach($values as $key => $value) {     echo isset($values[$key]) ? "TRUE " : "FALSE "; }
Answers:
• TRUE FALSE TRUE
• fatal error when using isset on an array
• TRUE FALSE FALSE
• TRUE TRUE TRUE
• FALSE FALSE FALSE
363. When passing an object to json_encode(), the default behavior can be modified by:
Answers:
• Implementing the JsonSerializable interface.
• Defining the __toJson() function.
• It's not possible to change the default behavior.
• Defining the __toArray() function.
364. What is the correct way to call an anonymous function?
Answers:
• $func($var);
• anonymous($var);
• callback($functionName, $var);
• call_function($var);
365. Given an array of images, $images = array("img12.png", "img10.png", "img2.png", "img1.png"), which function will sort $images into ("img1.png", "img2.png", "img10.png", "img12.png")?
Answers:
• natsort($images);
• ksort($images);
• usort($images);
• asort($images);
• arsort($images);
366. Which PHP function would you use to get information about the current session cookie?
Answers:
• session_get_cookie_params()
• session_set_cookie_params()
• get_cookie()
• set_cookie()
367. is_a( $a, $b ) will:
Answers:
• Check if $a is of type "$b"
• check if $a is of class "$b" or has this class as one of its parents
• it is not a built-in php function
368. How do you get the number of arguments passed to a PHP function?
Answers:
• $argc variable
• None of these
• $argv variable
• count() function
369. "virtual()" in PHP
Answers:
• marks the method as virtual, so it could be overridden
• is equivalent to the keyword "abstract"
• is an Apache-specific function
• makes the final method overrideable again
370. Which of the following code snippets will split a string into an array with 3 elements?
Answers:
• All of them
• $array = explode(" ", "a b c");
• $array = str_split("a b c", 2);
• $array = split(" ", "a b c");
• $array = sscanf("a b c", "%s %s %s");
371. An object can be counted with count() and sizeof() if it:
Answers:
• Was cast to an object from an array
• Has a public __count() method
• None of the above
• Implements ArrayAccess
372. Which type of error can NOT be caught with a custom error handler?
Answers:
• E_USER_ERROR
• E_RECOVERABLE_ERROR
• E_ERROR
• E_NOTICE
• E_WARNING
373. What is the output of the following code?  <?php echo str_pad("abc", 6, "7");  ?>
Answers:
• 777abc
• abcde777777
• abc777
• abcde67
• abcde6666666
374. What will be the final structure of the following array?  $animals = array(     'dog',        'cat',         true => 'lion' );
Answers:
• array( 0 => 'dog', 1 => 'cat' ) - element with boolean key will be ignored
• array( 0 => 'dog', 1 => 'cat', true => 'lion' )
• array( 0 => 'dog', 1 => 'lion' ) - boolean true will be changed to integer 1
• Syntax Error will be thrown, as all keys must be of the same type
• Syntax Error will be thrown, as array keys can't be boolean values
375. What is the value of $a in the following: <?php $a = array_pad( array( 0 ), 2, 1 ); ?>
Answers:
• array( 2 )
• array( 0, 1 )
• NULL
• array( 0, 2 )
376. use keyword is used only for namespace
Answers:
• true
• false
377. Which mode parameter should be used with the fopen() function to open a file and point to the end for writing only?
Answers:
• a+
• w
• a
• c+
378. $a = array('a' => 0, 'b' => 0, 'c' => 1, 'd' => 2); $b = array_flip($a); var_dump($b);  What does the 'var_dump' function show ?
Answers:
• array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" }
• array(4) { 'd' => int 2 'c' => int 1 'b' => int 0 'a' => int 0}
• array(3) { [0]=> string(1) "b" [1]=> string(1) "c" [2]=> string(1) "d" }
379. Which function would you use to obtain the ASCII value of a character?
Answers:
• chr( );
• ord( );
• val( );
• asc( );
380. What does the following PHP code do? preg_filter($pattern, $replace, $subject)
Answers:
• None of these
• Performs a regular expression search and replace
• Returns array entries that match the pattern
• Performs a regular expression search and replace using a callback
381. What does the glob() function return?
Answers:
• An array of all global variables into the user defined function
• An array of filenames / directories matching a specified pattern
• All system global variables
382. True or False? Within the eval() function, code must be opened and closed with PHP tags, i.e. <?php echo 'hi'; ?>
Answers:
• True, you MUST use PHP tags as everywhere
• False. You can't use PHP tags with eval()
• False, but you can still exit and enter PHP mode using tags
383. Sleep(3000); will sleep the page for?
Answers:
• 30 seconds
• 3000 seconds
• 3 seconds
• 300 seconds
384. Choose the correct output of:  <?php $email = 'admin@domain.tld'; echo strstr($email, '@'); ?>
Answers:
• domain.tld
• admin@domain.tld
• @domain.tld
• admin
385. Which of the following superglobals doesn't contain data from the client?
Answers:
• $_GET
• $_POST
• $_SESSION
• $_COOKIE
• $_SERVER
386. What are Traits in PHP?
Answers:
• Traits are class interfaces.
• Traits allow multiple inheritance for classes.
• Traits are all of these things.
• Traits allow code reuse without direct inheritance.
387. What is the time complexity of a call to array_search()?
Answers:
• O(N)
• O(N^2)
• O(N * log N)
• O(log N)
• O(1)
388. <?php  $x = false or true; $y = false || true; var_dump($x); var_dump($y);
Answers:
• bool(true) bool(false)
• bool(true) bool(true)
• bool(false) bool(true)
• bool(false) bool(false)
389. Which of the following functions inserts one or more elements to the beginning of an array?
Answers:
• array_shift()
• array_walk()
• array_push()
• array_merge()
• array_unshift()
390. Which elements can be encapsulated by namespaces?
Answers:
• Classes, functions, constants and variables
• Only classes
• Classes, functions and constants
391. Which function can be used to convert data into a binary string according to a specified format?
Answers:
• printf()
• pack()
• encode_hex()
• nex2bin()
392. What is the result of calling json_encode() on an empty array?
Answers:
• {} - An empty JavaScript object
• '' - An empty JavaScript string
• undefined
• [] - An empty JavaScript array
393. Which function returns an item from the argument list?
Answers:
• func_num_args()
• None of these
• func_get_arg()
• func_get_args()
394. What is the time complexity of a call to array_key_exists()?
Answers:
• O(1)
• O(N^2)
• O(N)
• O(log N)
• O(N * log N)
395. How do you call a static method defined by the called class from a parent class?
Answers:
• $obj = new __CLASS__; $obj->func();
• static::someFunc();
• self::someFunc();
• None of these. It is not supported in the language. Parent classes cannot access static methods defined by children.
• parent::func();
396. What does mt_srand( [int $a] ); do?
Answers:
• Initializes a random number generator
• Subtracts a random integer from the passed argument and returns the result
• Returns a random string of the length specified by the first argument
• This function does not exist
• Returns a random integer
397. Which of the following is the predefined class in PHP?
Answers:
• Special_Iterator
• __PHP_Incomplete_Class
• None of them
• PHP_RpcClient
• ErrorFault
398. Which of the following network transports doesn’t PHP support?
Answers:
• pdc
• tcp
• unix
• udg
399. What is the output for the following code? <?php $value1=5;  $value2= $value1--;  $value2= $value1++; echo $value2;  ?>
Answers:
• 2
• 0
• 4
• 5
• 3
400. What does this code do?  namespace Hello\World;
Answers:
• It creates two namespaces : "Hello" and "Hello\World"
• It creates one namespace : "Hello\World"
• It creates two namespaces : "Hello\World" and "World"
• It creates two namespaces : "Hello" and "World"
• It creates one namespace : "World"
401. What function allows you to print a backtrace?
Answers:
• backtrace_print
• debug_print_backtrace
• backtrace
• print_backtrace
• debug_backtrace_print
402. What data types cannot be used with PHP5 Type Hinting?
Answers:
• Strings, Interface
• Objects, Array
• Integer, Strings
• Integers, Array
403. Which of the following protocols is not supported by PHP streams?
Answers:
• ssh
• imap
• ftp
• bz2
404. What does this display?  <?php $x = array('a'=>1, 'b'=>2, 'c'=>3); echo key($x);
Answers:
• "a"
• array( 'a', 'b', 'c' )
• array( 0, 1, 2 )
• 0
405. Which function returns the size of a specified file on the FTP server?
Answers:
• get_ftp_size()
• ftp_amount()
• ftp_size()
• ftp_file_size()
406. $a = array('z','x','y'); $b = sort($a);  The value of $b is?
Answers:
• True
• array('x','y','z')
• array('z','y','x')
• False
407. Which of the following is not a valid PHP variable type conversion?
Answers:
• reference to array
• object to reference
• array to object
• string to object
408. When adding ('+' function) two variables of type integer and type string, what type is the resulting value?
Answers:
• Depends on the content of the string
• String
• Integer
409. Is there a function to listen on E_ERROR (fatal) errors?
Answers:
• set_error_handler()
• It's not possible
• register_shutdown_function()
410. Is it possible to typehint function arguments using native types (String, Bool, Array, Int, Float, Binary...)?
Answers:
• Only Array is supported
• All types except String
• Yes, using all types
411. Which PHP extension allows you to simplify converting between different calendar formats?
Answers:
• date/time
• calendar
• Julian
• All of these
412. What is the output of the following code: <?php $x = 0x22; echo <<<'END' $x END; ?>
Answers:
• 0x22
• 18
• 34
• $x
• Syntax error
413. What is the result of : $a = "abcd"; if(strpos('a', $a)) { return true; }  else { return false; }
Answers:
• false
• true
414. Which PHP function reads entire file into an array?
Answers:
• readfile
• file
• fopen
• fgets

• file_get_contents

No comments:

Post a Comment