Questions
PHP questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Pass Variables from PHP to JavaScript Safely
Learn how to pass PHP variables to JavaScript safely using json_encode, data attributes, and script blocks with practical examples.
How to Prevent SQL Injection in PHP
Learn how to prevent SQL injection in PHP using prepared statements, parameter binding, input validation, and safe database APIs.
How to Read a Large File Line by Line in Python
Learn how to read a large file line by line in Python without loading the whole file into memory and avoid out-of-memory errors.
How to Redirect in PHP with the header() Function
Learn how to redirect users in PHP using header(), including syntax, login protection, common mistakes, and real examples.
How to Remove Empty Array Elements in PHP
Learn how to remove empty strings from PHP arrays, why unset() inside foreach fails, and the best ways to clean user input safely.
How to Remove Spaces from a String in PHP
Learn how to remove spaces from a string in PHP using str_replace, regex, and trim, with examples, mistakes, and practical use cases.
How to Remove a Package in Laravel with Composer
Learn the correct way to remove a package from Laravel using Composer, including cleanup steps, service providers, aliases, and autoload refresh.
How to Remove the Last Character from a String in JavaScript
Learn how to remove a trailing character from a delimited string in JavaScript using slice, regex, and safe checks.
How to Return JSON from a PHP Script
Learn how to return JSON from PHP correctly using json_encode, proper headers, and practical examples for APIs and AJAX responses.
How to Sanitize User Input in PHP for SQL Injection and XSS
Learn how to sanitize and validate user input in PHP to prevent SQL injection and XSS while safely allowing selected HTML tags.
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 Show Useful Error Messages in PHP
Learn how to enable useful PHP error messages, debug blank pages, and configure error reporting safely in development and production.
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.
How to Sort an Array of Associative Arrays by Column Value in PHP
Learn how to sort an array of associative arrays by a column value in PHP using usort, comparison functions, and practical examples.
How to Sort an Array of Objects by Property in PHP
Learn how to sort an array of objects by a property in PHP using usort, spaceship operator, and custom comparison functions.
How to Structure the Model in MVC with PHP
Learn what belongs in the Model in MVC, how to separate entities and data access in PHP, and when extra layers improve code structure.
JSON vs serialize() in PHP: Choosing How to Store Arrays
Learn when to use JSON or serialize() to store PHP arrays, including performance, portability, pitfalls, and practical caching guidance.
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.
Multiple Where Clauses in Laravel Eloquent
Learn how to write multiple WHERE conditions in Laravel Eloquent using chained where calls, arrays, and grouped query logic.