Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
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.
How to Get the Full Current URL in PHP
Learn how to get the full current URL in PHP, including rewritten paths, query strings, and HTTPS, with practical examples and common pitfalls.
How to Get the Index in a foreach Loop in PHP
Learn how to access the index or key inside a PHP foreach loop, with syntax, examples, mistakes, and practical use cases.
How to Get the Last Character of a String in PHP
Learn how to get the last character of a string in PHP, with simple examples, edge cases, and common mistakes beginners should avoid.
How to Get the Last Element of an Array in PHP Without Removing It
Learn how to get the last element of a PHP array without deleting it, including indexed, associative, and sparse arrays.
How to Handle PHP Fatal Errors (E_ERROR) in PHP
Learn how PHP fatal errors work, why set_error_handler() cannot catch E_ERROR, and how to handle them using shutdown functions.
How to Hash Passwords with bcrypt in PHP
Learn what bcrypt is in PHP, how password_hash and password_verify work, and the correct way to store passwords securely.
How to Insert an Item Into an Array at Any Position in PHP
Learn how to insert a new item into a PHP array at any position using array_splice, with examples, mistakes, and practical use cases.
How to Install a Specific Package Version with Composer in PHP
Learn how to install a specific package version with Composer, including exact versions, constraints, updates, and common mistakes.
How to Parse and Process HTML/XML in PHP
Learn how to parse HTML and XML in PHP using DOMDocument, XPath, and SimpleXML to extract data safely and clearly.
How to Pass Arrays in a Query String in PHP and JavaScript
Learn how arrays are represented in query strings, what is and is not standardized, and how to parse them in PHP and JavaScript.