Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Fixing dyld Library Not Loaded Errors for PHP on macOS Homebrew
Learn why PHP fails with a missing icu4c dylib after Homebrew installs and how to diagnose and fix broken dynamic library links on macOS.
Format MySQL DATETIME Values in PHP with DateTime
Learn how to parse a MySQL DATETIME in PHP and format it as mm/dd/yy with a 12-hour time and AM/PM safely and clearly.
Format Numbers to Two Decimal Places in PHP
Learn how to format a PHP string number to two decimal places using number_format, rounding, and safe numeric conversion.
Generate Secure Unique Verification Tokens in PHP
Learn how to create secure, unique alphanumeric verification tokens in PHP using random_bytes, database constraints, expiry times, and safe links.
Get MySQL Table Column Names Using PHP
Learn how to retrieve MySQL table column names in PHP with PDO, SHOW COLUMNS, and INFORMATION_SCHEMA, including safe examples and common pitfalls.
Get a File Extension in PHP with pathinfo()
Learn how to get a filename extension in PHP using pathinfo(), why explode() returns an array, and how to validate uploaded images safely.
Group AND and OR Conditions in Laravel Eloquent Queries
Learn how to group AND and OR conditions in Laravel Eloquent with closure-based where clauses, avoid precedence bugs, and write readable queries.
HTTP_HOST vs SERVER_NAME in PHP: What’s the Difference?
Learn the difference between $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME'] in PHP, when to use each, and common pitfalls.
Handling PHP Warnings with try/catch and Error Handlers
Learn why PHP warnings bypass try/catch, how to handle dns_get_record failures safely, and when to use scoped error handlers.
How PHP foreach Actually Works with Arrays
Learn how PHP foreach works internally, including array copies, internal pointers, by-value vs by-reference behavior, and common pitfalls.
How to Add Elements to an Empty Array in PHP
Learn how to add values to an empty array in PHP using [] and array_push(), with examples, common mistakes, and real-world usage.
How to Add a New Column to an Existing Table in a Laravel Migration
Learn how to add a new column to an existing table in Laravel using migrations, Schema::table, and artisan commands.
How to Calculate the Difference Between Two Dates in PHP
Learn how to calculate the difference between two dates in PHP using DateTime and DateInterval, with examples and common mistakes.
How to Capture var_dump Output to a String in PHP
Learn how to capture var_dump output as a string in PHP using output buffering, with examples, pitfalls, and practical debugging use cases.
How to Change Maximum Upload File Size in PHP
Learn how PHP upload size limits work, which settings control them, and what to do when you cannot access php.ini or .htaccess.
How to Check If a String Is Valid JSON in PHP
Learn the correct and efficient way to check whether a string contains valid JSON in PHP using json_decode and json_last_error.
How to Check String Prefixes and Suffixes in PHP
Learn how to check whether a string starts or ends with specific text in PHP using simple functions and practical examples.
How to Check Whether a PHP Session Has Started
Learn how to safely detect and start PHP sessions, avoid duplicate session_start() calls, and handle $_SESSION correctly in PHP.
How to Check if a PHP Array Is Associative or Sequential
Learn how to detect associative vs sequential arrays in PHP, with clear examples, edge cases, and practical patterns for real code.
How to Check if a String Contains a Word in PHP
Learn how to check whether a PHP string contains a specific word using strpos and str_contains with clear examples and common mistakes.