Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Send a POST Request with PHP and Read the Response
Learn how to send POST requests in PHP, pass parameters, and read the response using cURL, streams, and practical examples.
How to Set Up UTF-8 End to End in PHP, MySQL, and Apache
Learn how to configure UTF-8 correctly across PHP, MySQL, Apache, HTML, and databases to avoid charset mismatches in web apps.
How to Sort a 2D Array by a Column Value in PHP
Learn how to sort a 2D array by a column value in PHP using usort, spaceship operator, and practical examples for associative arrays.
Long Polling vs SSE vs WebSockets vs Comet in JavaScript
Learn Long Polling, SSE, WebSockets, and Comet in JavaScript, how they keep connections open, and when to use each for real-time apps.
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 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 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 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 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.
Understanding "expects parameter 1 to be resource" in PHP MySQL Queries
Learn why mysql_fetch_array() expects a resource in PHP, how query failures happen, and how to fix SQL, variables, and deprecated mysql code.
Understanding Common PHP Errors, Warnings, and Notices
Learn what common PHP errors, warnings, and notices mean, why they happen, and how to debug and fix them effectively.
Understanding Undefined Variable, Undefined Index, Array Key, and Offset Notices in PHP
Learn what PHP undefined variable, index, array key, and offset messages mean, why they appear, and how to fix them safely.
What Is stdClass in PHP? A Beginner-Friendly Guide
Learn what stdClass is in PHP, how it works, when PHP creates it automatically, and how to use it with practical examples.