Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Delete an Element from an Array in PHP
Learn how to remove array elements in PHP using unset, array_filter, and reindexing, with examples and common mistakes explained clearly.
How to Detect HTTP Request Methods in PHP (GET, POST, PUT, DELETE)
Learn how to detect GET, POST, PUT, and DELETE requests in PHP using REQUEST_METHOD, with examples, pitfalls, and real-world usage.
How to Detect the First and Last Iteration in a foreach Loop in PHP
Learn how to detect the first and last iteration in a PHP foreach loop using counters, array keys, and practical beginner-friendly examples.
How to Display PHP Errors in the Browser
Learn how PHP error display works, why blank pages happen, and how to enable useful errors during development safely.
How to Expire a PHP Session After 30 Minutes
Learn how to expire a PHP session after 30 minutes using inactivity timeouts, session checks, and safe logout logic in PHP.
How to Find and Configure php.ini in PHP
Learn where php.ini is located, how PHP loads configuration files, and how to enable extensions like ibm_db2 safely and correctly.
How to Find the Number of Days Between Two Dates in PHP
Learn how to calculate the number of days between two dates in PHP using DateTime, diff(), timestamps, and common best practices.
How to Fix "Cannot Use Object of Type stdClass as Array" in PHP json_decode()
Learn why json_decode() returns stdClass objects in PHP and how to correctly access values as objects or associative arrays.
How to Fix PHP Allowed Memory Size Exhausted Errors When Sending Large XML-RPC Payloads
Learn why PHP memory exhausted errors happen with large XML-RPC requests and how to reduce memory use in PHP and CodeIgniter apps.
How to Fix PHP Parse and Syntax Errors
Learn how to read PHP parse errors, find the real cause, and fix common syntax mistakes with practical examples and debugging steps.
How to Fix the "Headers Already Sent" Error in PHP
Learn why PHP shows "Headers already sent" and how to fix it when using header() or setcookie() with clear examples.
How to Format Numbers with Leading Zeros in PHP
Learn how to add leading zeros in PHP using str_pad and sprintf, with examples, pitfalls, and real-world use cases.
How to Get Raw SQL from Laravel Query Builder
Learn how to view the raw SQL generated by Laravel's query builder, including toSql(), bindings, and common debugging patterns.
How to Get a File Extension in PHP
Learn the best way to get a file extension in PHP, including pathinfo(), edge cases, examples, and common mistakes beginners make.
How to Get a YouTube Video Thumbnail in PHP Using the YouTube API
Learn how to get a YouTube video thumbnail from a YouTube URL in PHP using the YouTube Data API and simple thumbnail URLs.
How to Get the Client IP Address in PHP
Learn how to get a client IP address in PHP, when to use REMOTE_ADDR, and how to safely handle proxies and logging.
How to Get the Current Date and Time in PHP
Learn how to get the current date and time in PHP using date(), time(), and DateTime with clear examples and common mistakes.
How to Get the Current Year in PHP for Dynamic Copyright Footers
Learn how to get the current year in PHP and use it in a dynamic copyright footer that updates automatically every year.
How to Get the First Element of an Array in PHP
Learn how to get the first element of a PHP array without using array_shift or passing by reference, with examples and common pitfalls.
How to Get the First Key of an Array in PHP
Learn how to get the first key of an array in PHP, including associative arrays, older approaches, and common mistakes to avoid.