Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
PHP Date and Time Formatting Like MySQL NOW()
Learn how to generate a MySQL NOW()-style datetime string in PHP using date() and understand formatting, timestamps, and common mistakes.
PHP Elvis Operator (?:) vs Null Coalescing Operator (??)
Learn the difference between PHP's short ternary operator (?:) and null coalescing operator (??) with examples, edge cases, and best practices.
PHP Enumerations: How to Model Enums Before and With Native Enums
Learn how to represent enumerations in PHP, common workarounds, native enum syntax, and when to use constants or enum classes.
PHP Equality vs Identity: Understanding == and ===
Learn the difference between PHP == and ===, how loose and strict comparisons work, and when to use each with clear examples.
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 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 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 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.
SQL Injection and mysql_real_escape_string() in PHP
Learn when mysql_real_escape_string() helps, where it fails, and why prepared statements are the safe way to prevent SQL injection in PHP.
Secure Password Hashing in PHP: Salts, password_hash(), and Best Practices
Learn secure password hashing in PHP using salts, password_hash(), and password_verify() instead of MD5 or SHA for safe storage.
Single vs Double Quoted Strings in PHP
Learn the difference between single-quoted and double-quoted strings in PHP, including interpolation, escape sequences, and common mistakes.