Questions

PHP questions

Choose a question page, learn the concept, then test your understanding with a quiz.

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.

phpurl

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.

phploopsforeach

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.

phpstring

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.

phparrays

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.

phpfatal-error

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.

phppasswordscryptographypassword-protection

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.

phparraysinsert

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.

phpcomposer-phpdependency-management

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.

phphtmlxmlxml-parsing

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.

phparraysquery-stringquerystringparameter

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.

phpjavascript

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.

phpmysqlsqlsecurity

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.

php

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.

phphttp-redirecthttp-status-code-301

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.

phparraysstring

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.

phpstringspaces

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.

phplaravelcomposer-phpuninstallation

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.

phpcsvdelimitertruncate

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.

phpjsonheader

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.

phpsecurityxsssql-injection

Page 4 of 7 - 136 questions