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.

phpdatetimetimetimestamp

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.

phpconditional-operatornull-coalescing-operatorelvis-operator

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.

phpenumeration

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.

phpoperators

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.

phpoperator-keyword

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.

phpstringrandom

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.

phpphp-shorttags

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.

phpargumentsoperatorssymbols

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.

phpmultithreadingpackagethread-safety

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().

phpstring

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.

phphttpcurlhttp-post

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.

phpconstantspsr-1psr-12

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.

phpstaticlate-static-binding

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.

phpincluderequirerequire-once

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.

phpclassoopscope

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.

phpjsonpretty-print

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.

phpoopprivatepublic

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.

phpmysqlsqlsecurity

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.

phpsecurityhashpasswords

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.

phpstringsyntax

Page 5 of 6 - 112 questions