// Learn
// Try It
// Reference
<?php
The server awaits
PHP powers over 75% of the web. Master the fundamentals — variables, arrays, functions, OOP, forms, databases, and more.
PHP/HTML
CSS
JS
Preview
sandbox://preview
PHP Fundamentals Reference
// variables · arrays · functions · OOP · forms · database
| Concept | Rarity | Purpose | Key Syntax |
|---|---|---|---|
echo / print | Rare | Output text to browser | echo "text"; |
$variables | Rare | Store values with $ prefix | $name = "PHP"; |
Data Types | Rare | string, int, float, bool, null, array | gettype($var) |
String Functions | Rare | Manipulate strings | strlen(), strtoupper(), str_replace() |
if / else / elseif | Rare | Conditional branching | if ($x > 0) { ... } |
switch / match | Rare | Multi-value branching | match($val) { 1 => "one" } |
for / while / foreach | Rare | Loop over data | foreach($arr as $k => $v) |
Indexed Arrays | Rare | List of ordered values | $arr = [1, 2, 3]; |
Associative Arrays | Rare | Key-value pairs | $user = ["name" => "Ana"]; |
Array Functions | Epic | Sort, filter, map arrays | array_map(), array_filter() |
Functions | Rare | Reusable code blocks | function greet($name) { ... } |
Arrow Functions | Epic | Short closures (PHP 7.4+) | $fn = fn($x) => $x * 2; |
Variable Scope | Epic | global, static, local vars | global $var; static $count; |
Classes & Objects | Epic | OOP blueprint and instance | class Dog { public $name; } |
Inheritance | Epic | Extend a parent class | class Cat extends Animal |
Interfaces & Abstract | Legend | Contracts and partial classes | interface Drawable { ... } |
Traits | Legend | Reusable method bundles | use Logging; |
$_GET / $_POST | Rare | Handle form data | $_POST['email'] |
Form Validation | Rare | Sanitize & validate input | filter_var(), htmlspecialchars() |
Sessions | Epic | Persist data across pages | session_start(); $_SESSION |
Cookies | Rare | Store data in browser | setcookie("name", "val", time()+3600) |
File Handling | Epic | Read and write files | file_get_contents(), fopen() |
PDO Database | Epic | Query databases safely | $pdo->prepare($sql)->execute() |
Error Handling | Epic | try/catch exceptions | try { } catch (Exception $e) { } |
Namespaces & Autoload | Legend | Organize large codebases | namespace App\Models; |