Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
PHP Maximum Execution Time Exceeded: Diagnose and Fix Long-Running Scripts
Learn why PHP scripts exceed maximum execution time, how to diagnose slow loops and downloads, and safely use timeouts, batching, and pagination.
PHP Newline Characters: Single vs Double Quotes
Learn why PHP prints \r\n literally in single quotes and how to create real newline characters for text files, browsers, and Windows Notepad.
PHP Null Coalescing Operator (??): Meaning, Usage, and Examples
Learn what the PHP null coalescing operator (??) means, how it differs from isset() and ?:, and how to use it safely in real code.
PHP Random String Generator: Return Values, Scope, and Correct String Building
Learn how to generate a random string in PHP, fix scope mistakes, and build strings correctly with practical examples.
PHP Short Tags Explained: Should You Use `<?` and `<?=` in PHP?
Learn when PHP short tags are acceptable, why they are discouraged, and how `<?`, `<?=`, and `<?php` differ in real projects.
PHP Static Code Analysis: Finding Bugs Beyond Syntax
Learn how PHP static analysis finds type errors, undefined variables, dead code, and style issues before runtime, with practical PHP examples.
PHP Syntax Symbols Explained: Operators, Tokens, and What They Mean
Learn what common PHP syntax symbols mean, including operators like ==, ===, ->, =>, ??, ?:, and more with clear examples.
PHP Thread Safe vs Non-Thread Safe: What It Means and Which One to Use
Learn what thread-safe and non-thread-safe PHP builds mean, how they differ, and which PHP package to choose for Apache, FastCGI, and CLI use.
PHP Variable to String: PHP Equivalent of Java/.NET ToString()
Learn how to convert PHP values to strings, when casting works, and how __toString() compares to Java and .NET ToString().
PHP cURL Custom Headers: Sending HTTP Request Headers
Learn how to send custom HTTP headers with PHP cURL using CURLOPT_HTTPHEADER, including syntax, examples, debugging, and common mistakes.
PHP cURL HTTP POST Example: Sending Form Data and Reading the Response
Learn how to make an HTTP POST request with PHP cURL, send form data, and read the server response with clear examples.
PHP define() vs const: Differences, Usage, and Best Practices
Learn the difference between define() and const in PHP, when to use each, and how constants behave in classes, files, and runtime code.
PHP json_decode(): Decode JSON as an Associative Array
Learn why json_decode returns stdClass objects by default in PHP and how to decode JSON into associative arrays safely and correctly.
PHP new self vs new static: Understanding Late Static Binding
Learn the difference between `new self` and `new static` in PHP, including late static binding, inheritance behavior, and practical examples.
PHP require vs include vs require_once vs include_once Explained
Learn the difference between require, include, require_once, and include_once in PHP, with examples, errors, and when to use each one.
PHP self vs $this: Difference, Usage, and When to Use Each
Learn the difference between self and $this in PHP, when to use each, and how static vs instance context works with clear examples.
Pretty-Printing JSON in PHP with json_encode
Learn how to pretty-print JSON in PHP using json_encode, including syntax, examples, common mistakes, and real-world usage.
Public vs Private vs Protected in PHP Classes
Learn the difference between public, private, and protected in PHP classes, when to use each, and how visibility affects methods and properties.
Python Equivalent of PHP var_dump(): repr, pprint, type, and vars
Learn Python alternatives to PHP var_dump(), including repr(), pprint(), type(), vars(), and inspect tools for clear debugging output.
Run a Single PHPUnit Test Method with --filter
Learn how PHPUnit's --filter option selects one PHP test method, including regex patterns, command argument order, and reliable examples.