Questions

PHP questions

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

Replace Only the First String Match in PHP

Learn how to replace only the first occurrence of a string in PHP using preg_replace with a limit or strpos and substr_replace safely.

phpstring

Run a Single PHPUnit Test Method with --filter

Learn how PHPUnit's --filter option selects one PHP test method, including regex patterns, command argument order, and reliable examples.

phpphpunit

SQL Injection and mysql_real_escape_string() in PHP

Learn when mysql_real_escape_string() helps, where it fails, and why prepared statements are the safe way to prevent SQL injection in PHP.

phpmysqlsqlsecurity

Save an Image from a URL in PHP

Learn how to download and save an image served by a PHP URL using PHP streams or cURL, with safe filenames, error handling, and validation.

phpimage

Secure Database Passwords in PHP: Environment Variables and Secret Management

Learn how to secure PHP database passwords with environment variables, protected configuration, least privilege, and secret managers.

phpdatabasesecurity

Secure Password Hashing in PHP: Salts, password_hash(), and Best Practices

Learn secure password hashing in PHP using salts, password_hash(), and password_verify() instead of MD5 or SHA for safe storage.

phpsecurityhashpasswords

Single vs Double Quoted Strings in PHP

Learn the difference between single-quoted and double-quoted strings in PHP, including interpolation, escape sequences, and common mistakes.

phpstringsyntax

Testing Exceptions with PHPUnit in PHP

Learn how to test expected exceptions in PHPUnit using expectException, message and code assertions, plus common pitfalls and examples.

phpexceptionphpunitassert

Understanding "expects parameter 1 to be resource" in PHP MySQL Queries

Learn why mysql_fetch_array() expects a resource in PHP, how query failures happen, and how to fix SQL, variables, and deprecated mysql code.

phpmysql

Understanding Common PHP Errors, Warnings, and Notices

Learn what common PHP errors, warnings, and notices mean, why they happen, and how to debug and fix them effectively.

phparraysdebuggingerror-handling

Understanding T_PAAMAYIM_NEKUDOTAYIM in PHP: What the Error Means

Learn what the PHP T_PAAMAYIM_NEKUDOTAYIM error means, why it happens, and how to fix scope resolution operator mistakes clearly.

phpruntime-errorsyntax-errorerror-code

Understanding Undefined Variable, Undefined Index, Array Key, and Offset Notices in PHP

Learn what PHP undefined variable, index, array key, and offset messages mean, why they appear, and how to fix them safely.

phparraysvariableswarnings

Using PHP cURL with a SOCKS5 Proxy to Access Tor .onion Services

Learn why PHP cURL fails on .onion hostnames and how to use SOCKS5 hostname resolution correctly with Tor hidden services.

phpcurlproxytor

What Is stdClass in PHP? A Beginner-Friendly Guide

Learn what stdClass is in PHP, how it works, when PHP creates it automatically, and how to use it with practical examples.

phpstdclass

What the @ Symbol Means in PHP: Error Suppression Explained

Learn what the @ symbol does in PHP, how error suppression works, when to avoid it, and safer alternatives with examples.

phpoperatorserror-suppression

When to Use Single Quotes, Double Quotes, and Backticks in MySQL

Learn when to use single quotes, double quotes, and backticks in MySQL, with examples, rules, mistakes, and safe query practices.

phpsqlmysqlquotes

Why PHP mail() Does Not Send Email: Troubleshooting Form Email in PHP

Learn why PHP mail() may fail to send form emails and how to validate input, configure mail properly, and debug PHP email issues.

phphtmlfunctionemail

Why You Should Not Use mysql_* Functions in PHP

Learn why mysql_* functions are obsolete in PHP, what risks they cause, and which modern alternatives to use instead.

phpmysql

die() vs exit() in PHP: Differences, Behavior, and When to Use Them

Learn the difference between die() and exit() in PHP, how they work, whether they are aliases, and when to use each in real code.

phpexitdie

htmlspecialchars() vs htmlentities() in PHP: Differences and When to Use Each

Learn the difference between htmlspecialchars() and htmlentities() in PHP, when to use each, and how to safely escape HTML output.

php

Page 8 of 9 - 162 questions