Zend PHP 5 3 Practice Exam, Exams of Technology

Similar to the Zend PHP 5 exam, this version focuses specifically on PHP 5.3. Topics covered include advanced features in PHP 5.3, including namespaces, late static binding, and other enhancements.

Typology: Exams

2025/2026

Available from 01/13/2026

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 80

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Zend PHP 5 3 Practice Exam
Question 1. Which of the following PHP tags is used to output a variable's value directly within HTML?
A) <?php ?>
B) <?= ?>
C) <!--php-->
D) <? ?>
Answer: B
Explanation: The <?= ?> tag is shorthand for <?php echo ?> and outputs a variable's value
directly.
Question 2. How do you write a single-line comment in PHP?
A) //
B) ##
C) <!-- -->
D) ***
Answer: A
Explanation: Single-line comments use // or #, but // is the most common.
Question 3. Which keyword is used to declare a constant inside a class in PHP?
A) define
B) const
C) static
D) var
Answer: B
Explanation: The ‘const’ keyword declares class constants.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50

Partial preview of the text

Download Zend PHP 5 3 Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which of the following PHP tags is used to output a variable's value directly within HTML? A) <?php ?> B) <?= ?> C) <!--php--> D) <? ?> Answer: B Explanation: The <?= ?> tag is shorthand for <?php echo ?> and outputs a variable's value directly. Question 2. How do you write a single-line comment in PHP? A) // B) ## C) <!-- --> D) *** Answer: A Explanation: Single-line comments use // or #, but // is the most common. Question 3. Which keyword is used to declare a constant inside a class in PHP? A) define B) const C) static D) var Answer: B Explanation: The ‘const’ keyword declares class constants.

Question 4. What is the result of the expression 5 + "5" in PHP? A) "55" B) 10 C) 5 D) Error Answer: B Explanation: PHP type-juggles the string "5" to integer, so 5 + 5 = 10. Question 5. What does the require statement do if the specified file is not found? A) Emits a warning and continues B) Emits an error and stops execution C) Silently ignores D) Returns false Answer: B Explanation: require triggers a fatal error and halts execution if the file is missing. Question 6. Which function checks whether a variable is of array type? A) gettype() B) array_type() C) is_array() D) check_array() Answer: C Explanation: is_array() returns true if the variable is an array. Question 7. How do you declare a variable with global scope inside a function?

B) array_combine() C) array_join() D) array_union() Answer: A Explanation: array_merge() merges the elements of one or more arrays. Question 11. What is the default scope of a variable declared inside a PHP function? A) Global B) Static C) Local D) Public Answer: C Explanation: Variables declared inside a function are local by default. Question 12. How do you define a multi-line comment in PHP? A) // ... // B) /* ... / C) <!-- ... --> D) ## ... ## Answer: B Explanation: Multi-line comments use / ... */. Question 13. What does the include_once statement do? A) Includes a file every time it is called B) Includes a file only if it hasn't been included before

C) Includes a file and stops execution D) Includes multiple files at once Answer: B Explanation: include_once includes the file only if it hasn’t been included already. Question 14. Which function can be used to check the type of a variable? A) checktype() B) gettype() C) is_type() D) type_of() Answer: B Explanation: gettype() returns the type of a variable as a string. Question 15. How do you pass a variable by reference to a function? A) function foo(&$var) B) function foo(*$var) C) function foo($var&) D) function foo(ref $var) Answer: A Explanation: The ampersand (&) before $var passes it by reference. Question 16. Which of the following is NOT a scalar type in PHP? A) boolean B) integer C) array

Answer: D Explanation: foreach iterates over arrays and objects that implement Traversable. Question 20. How do you declare a HEREDOC string in PHP? A) <<<"EOD" B) <<EOD C) <<<EOD D) <<<'EOD' Answer: C Explanation: HEREDOC uses <<<EOD (identifier can vary). Question 21. Which function returns the length of a string? A) strlen() B) string_length() C) length() D) count() Answer: A Explanation: strlen() returns the number of bytes in a string. Question 22. How can you remove whitespace from the beginning and end of a string? A) strip() B) trim() C) cut() D) clean() Answer: B

Explanation: trim() removes leading and trailing whitespace. Question 23. What does mb_strlen() do differently than strlen()? A) Counts only ASCII characters B) Counts bytes instead of characters C) Handles multibyte character encodings D) Ignores whitespace Answer: C Explanation: mb_strlen() counts characters in multibyte encodings like UTF-8. Question 24. Which regular expression function splits a string by a pattern? A) preg_split() B) preg_match() C) split() D) explode() Answer: A Explanation: preg_split() splits a string using a regular expression pattern. Question 25. What does the PCRE modifier ‘i’ do in preg_match()? A) Makes the match case-insensitive B) Allows multiline matching C) Repeats the match D) Ignores whitespace Answer: A Explanation: The 'i' modifier makes pattern matching case-insensitive.

Question 29. Which magic method is called when an object is cloned? A) __clone() B) __copy() C) __new() D) __construct() Answer: A Explanation: __clone() is called when an object is cloned. Question 30. What is the purpose of the abstract keyword in a class definition? A) Prevents instantiation of the class B) Allows only static methods C) Requires inheritance D) Makes all methods private Answer: A Explanation: Abstract classes cannot be instantiated directly. Question 31. How do you implement an interface in PHP? A) use InterfaceName; B) implements InterfaceName C) extends InterfaceName D) require InterfaceName Answer: B Explanation: Classes implement interfaces using 'implements'. Question 32. Which keyword is used to prevent a method from being overridden?

A) final B) static C) private D) sealed Answer: A Explanation: final prevents a method from being overridden in a subclass. Question 33. What is the benefit of using traits in PHP? A) Multiple inheritance B) Code reusability in classes C) Access to private properties D) Faster execution Answer: B Explanation: Traits provide code reuse among classes. Question 34. What does the static keyword mean for a class property? A) It is accessible only outside the class B) It is shared among all instances C) It is initialized once per object D) It is immutable Answer: B Explanation: Static properties are shared across all instances. Question 35. How do you refer to the current class in static context? A) $this

C) __call() D) __toString() Answer: A Explanation: __get() is invoked when reading inaccessible properties. Question 39. What is type hinting in function arguments? A) Restricts argument type B) Forces return type C) Prevents method overriding D) Specifies default value Answer: A Explanation: Type hinting restricts the type of argument passed to a function. Question 40. Which function provides information about classes and their properties? A) info_class() B) get_class_info() C) ReflectionClass D) class_details() Answer: C Explanation: ReflectionClass provides introspection of classes. Question 41. What is a namespace in PHP? A) A group of files B) A way to encapsulate code and avoid name collisions C) A data type

D) An access modifier Answer: B Explanation: Namespaces help organize code and prevent naming conflicts. Question 42. How do you import a namespace in PHP? A) import B) use C) namespace D) require Answer: B Explanation: The use keyword imports namespaces. Question 43. Which superglobal contains data sent via HTTP GET? A) $_POST B) $_REQUEST C) $_GET D) $_SESSION Answer: C Explanation: $_GET contains query string parameters from HTTP GET requests. Question 44. How do you process a file upload in PHP? A) $_FILES B) $_UPLOAD C) $_REQUEST D) $_POST

Explanation: header() sends raw HTTP headers. Question 48. What happens if headers are sent after output in PHP? A) Headers are sent normally B) PHP throws a warning C) Execution stops D) The output is buffered Answer: B Explanation: Headers must be sent before any output; otherwise, a warning occurs. Question 49. Which extension is preferred for database interaction in PHP 5.3? A) mysql B) PDO C) odbc D) pgsql Answer: B Explanation: PDO is preferred for its flexibility and security. Question 50. What is the main advantage of prepared statements in PDO? A) Faster execution B) Prevention of SQL injection C) Supports multiple databases D) Automatic query optimization Answer: B Explanation: Prepared statements prevent SQL injection.

Question 51. How do you start a transaction in PDO? A) startTransaction() B) beginTransaction() C) transactionStart() D) begin() Answer: B Explanation: beginTransaction() starts a transaction. Question 52. Which function executes a SQL query using PDO? A) run() B) execute() C) query() D) fetch() Answer: C Explanation: query() executes a SQL statement and returns a result set. Question 53. How do you fetch a single row from a PDO result? A) fetchRow() B) fetch() C) getRow() D) single() Answer: B Explanation: fetch() retrieves the next row from a result set.

A) setCustomErrorHandler() B) set_error_handler() C) errorHandler() D) custom_error() Answer: B Explanation: set_error_handler() sets a user-defined error handler. Question 58. Which function throws an exception in PHP? A) throw() B) raise() C) exception() D) throw new Exception() Answer: D Explanation: 'throw new Exception()' throws an exception object. Question 59. What does the finally block do in try...catch...finally? A) Executes if no exception B) Executes always C) Executes only on error D) Terminates script Answer: B Explanation: The finally block always executes, regardless of exceptions. Question 60. Which class is the base for all exceptions? A) Throwable

B) Error C) Exception D) BaseException Answer: C Explanation: Exception is the base class for all exceptions. Question 61. How do you execute code after script completion? A) after_script() B) end_script() C) register_shutdown_function() D) shutdown() Answer: C Explanation: register_shutdown_function() executes code after script completion. Question 62. Which function reads the entire contents of a file into a string? A) fread() B) file_get_contents() C) readfile() D) file() Answer: B Explanation: file_get_contents() reads a file into a string. Question 63. How do you write data to a file in PHP? A) fwrite() B) file_write()