PHP - MCQ Questions and Answers

Test your knowledge of PHP with these interactive multiple-choice questions.

« First 7 8 9 10 Last »
« Previous Page Next Page »

181. What is the purpose of PHP's Fibers in 8.1+?

  • a) Lightweight cooperative multitasking
  • b) Parallel thread execution
  • c) Asynchronous I/O operations
  • d) Both A and C
Answer: D - Fibers enable suspendable functions without full threading, ideal for async I/O.

182. Which PHP 8.2 feature improves type system expressiveness?

  • a) DNF Types
  • b) Generic Types
  • c) Typed Properties
  • d) Type Erasure
Answer: A - Disjunctive Normal Form types allow (A&B)|C type combinations.

183. What is the purpose of PHP's WeakMaps?

  • a) Memory-efficient object-keyed maps
  • b) Thread-safe array alternative
  • c) Persistent storage
  • d) Encrypted data structures
Answer: A - WeakMaps don't prevent garbage collection of their keys (unlike SplObjectStorage).

184. Which tool analyzes PHP memory usage in real-time?

  • a) Meminfo
  • b) Xdebug
  • c) Blackfire
  • d) Tideways
Answer: A - Meminfo provides detailed heap snapshots for memory leak detection.

185. What is the purpose of PHP's Attributes (annotations)?

  • a) Structured metadata for classes/properties
  • b) Documentation generation
  • c) Runtime code modification
  • d) All of the above
Answer: D - Attributes replace docblock annotations with first-class syntax.

186. Which PHP 8.3 feature improves JSON validation?

  • a) json_validate()
  • b) JSON_THROW_ON_ERROR
  • c) json_parse()
  • d) FilterJSON extension
Answer: A - New json_validate() function checks syntax without parsing.

187. What is the purpose of PHP's preloading in 7.4+?

  • a) Loads classes into OPcache at startup
  • b) Prefetches database results
  • c) Compiles templates in advance
  • d) Caches configuration files
Answer: A - Preloading reduces autoloading overhead for critical classes.

188. Which PHP 8.1 feature improves enum capabilities?

  • a) Backed enums
  • b) Enum methods
  • c) Enum interfaces
  • d) All of the above
Answer: D - PHP 8.1 enums support scalar values, methods, and interfaces.

189. What is the purpose of PHP's JIT in 8.0+?

  • a) Compiles hot paths to machine code
  • b) Just-In-Time dependency injection
  • c) Dynamic typing
  • d) Template compilation
Answer: A - JIT improves CPU-bound performance by native compilation.

190. Which tool visualizes PHP service dependencies in microservices?

  • a) OpenTelemetry
  • b) Zipkin
  • c) Jaeger
  • d) All of the above
Answer: D - All provide distributed tracing for service maps.

191. What is the purpose of PHP's #[SensitiveParameter] attribute?

  • a) Redacts sensitive data in stack traces
  • b) Encrypts parameter values
  • c) Validates input sanitization
  • d) Marks PII for GDPR compliance
Answer: A - Hides values (like passwords) in error logs (PHP 8.2+).

192. Which PHP 8.3 feature improves random number generation?

  • a) Randomizer class
  • b) random_bytes() enhancement
  • c) CSPRNG extension
  • d) SecureRandom interface
Answer: A - New Randomizer provides shuffle(), getBytes(), etc. methods.

193. What is the purpose of PHP's FFI in 7.4+?

  • a) Calls C libraries directly
  • b) Foreign function integration
  • c) Both A and B
  • d) JavaScript interoperability
Answer: C - Foreign Function Interface interacts with C code without extensions.

194. Which PHP 8.2 change improves type inference?

  • a) Standalone null/false types
  • b) Type widening
  • c) Type narrowing
  • d) All of the above
Answer: D - Allows more precise type annotations and checks.

195. What is the purpose of PHP's array_is_list() in 8.1+?

  • a) Checks if array is a sequential list
  • b) Validates array structure
  • c) Converts objects to arrays
  • d) Sorts associative arrays
Answer: A - Returns true for arrays with sequential 0-based integer keys.

196. Which PHP 8.3 feature improves class constant visibility?

  • a) Typed constants
  • b) Final constants
  • c) Dynamic constant fetch
  • d) All of the above
Answer: A - Constants can now have type declarations (e.g., const string FOO = 'bar').

197. What is the purpose of PHP's #[Override] attribute?

  • a) Marks intentional method overrides
  • b) Enforces polymorphism
  • c) Both A and B
  • d) Replaces abstract methods
Answer: C - Ensures parent class has matching method (PHP 8.3+).

198. Which PHP 8.2 feature deprecates dynamic properties?

  • a) #[AllowDynamicProperties]
  • b) StrictProperties mode
  • c) declare(strict_properties=1)
  • d) final class properties
Answer: A - Classes now forbid dynamic properties unless explicitly allowed.

199. What is the purpose of PHP's deep clone feature in 8.1+?

  • a) Recursive object cloning
  • b) __clone() method enhancement
  • c) Serialized cloning
  • d) Immutable object duplication
Answer: A - readonly properties can now be reinitialized during cloning.

200. Which PHP 8.3 feature improves unserialization security?

  • a) Allowed classes list
  • b) Serialized data validation
  • c) unserialize() strict mode
  • d) All of the above
Answer: A - New $allowed_classes parameter restricts unserialization targets.
« First 7 8 9 10 Last »
« Previous Page Next Page »

Learn Computer Skills with PCBooks

Master computer skills with PCBooks! Explore interactive tutorials, MCQ tests, and online exams for programming, web development, and IT fundamentals. Perfect for beginners and advanced learners.

Online MCQ Tests for Programming

Practice programming MCQ questions and improve your coding skills with our online quizzes. Whether you're learning Python, Java, or C programming, PCBooks has you covered.

Free Web Development Tutorials

Learn HTML, CSS, and JavaScript with our free web development tutorials. Test your knowledge with interactive quizzes and online exams.