What Is Variable Scope in PHP (global, local, static)?
PHP variable scope controls where a variable can be used. Learn local, global and static variables and why passing parameters beats the global keyword.
59 posts about PHP: questions with answers, tutorials and articles, newest first.
PHP variable scope controls where a variable can be used. Learn local, global and static variables and why passing parameters beats the global keyword.
Type juggling is PHP converting types for you, and casting is doing it yourself. See the rules, the PHP 8 changes and how strict_types helps.
The spaceship operator compares two values in one expression and returns -1, 0 or 1, which makes sort callbacks short and safe.
Understand the php null coalescing operator with examples of defaults, chaining, nested access and the ??= assignment form, plus how it differs from ?:.
A beginner guide to PHP logical operators with examples of short-circuiting, truthy and falsy values, and the precedence difference between && and and.
Understand php == vs === with examples, the PHP 8 changes to string and number comparison, the spaceship operator and traps like in_array and strpos.
A clear guide to PHP arithmetic and assignment operators with examples for division, modulo, compound assignment, increment and precedence.
Define PHP constants with const and define(), compare the two, and learn class constants, magic constants and the rules for using them.
A beginner guide to PHP data types with runnable examples, type checking functions, automatic conversion and strict type declarations.
echo and print both output text in PHP. Learn the exact differences in arguments and return value, the short echo tag and which to use.
Declare PHP variables with a dollar sign, learn the naming rules, types and scope, and avoid the common beginner mistakes.
PHP supports single-line, multi-line and docblock comments. See the syntax, the nesting and closing tag pitfalls, and how to write useful comments.
See what PHP 8 added over PHP 7, from named arguments and match to the JIT, plus the breaking changes to check before you upgrade.
Compare PhpStorm, Visual Studio Code and lightweight editors for PHP, see which features matter, and pick a setup that suits a beginner.
phpMyAdmin is a browser-based tool for MySQL and MariaDB. Learn to log in, create tables, run SQL, back up data and keep the login page safe.
php.ini controls PHP's runtime settings. Learn how to locate the right file, change directives, restart the service and confirm the change took effect.
Start a local PHP server with php -S, serve a public folder, route pretty URLs with a router script and learn why it is for development only.
Learn to run PHP scripts, one-liners and the interactive shell from a terminal, pass arguments, read input and set exit codes.
Create hello.php, run it with the php command or the built-in server, then mix PHP with HTML and learn the basic syntax and common errors.
Install PHP on Ubuntu with apt, add extensions, switch versions and serve pages with Apache, Nginx and PHP-FPM or the built-in server.