Server-side Programming — Basics, Forms, OOP, Interfaces, Traits, Namespaces, Exceptions
PHP tags, echo/print, variables ($), data types, comments, string concatenation
if/elseif/else, switch/case, match expression, comparison operators, null coalescing
for, while, do-while, foreach — array iterate, break, continue
function declaration, parameters, default values, return, built-in functions
Indexed, associative, multidimensional arrays, array functions
strlen, strtolower/upper, str_replace, explode, implode, substr, trim
$_GET, $_POST, $_REQUEST, htmlspecialchars, form validation, superglobals
<?php
$name = "Min";
echo "Hello " . $name;
// comment
$str = "hello";
$num = 42;
$float = 3.14;
$bool = true / false;
if ($x > 5) { }
elseif ($x == 5) { }
else { }
$y = $x ?? "default";
for ($i=0; $i<5; $i++)
while ($cond) { }
foreach ($arr as $v)
foreach ($arr as $k=>$v)
$arr = [1, 2, 3];
$map = ["name"=>"Min"];
count($arr);
array_push($arr, 4);
strlen($s)
strtolower($s)
str_replace("a","b",$s)
explode(",", $s)
$_GET["name"]
$_POST["email"]
htmlspecialchars($val)
isset($_POST["btn"])
function add($a, $b=0) {
return $a + $b;
}
echo add(3, 4);
class, constructor, visibility (public/protected/private), static, magic methods, PHP 8 constructor promotion
extends, parent::, method overriding, abstract class, polymorphism, final
interface, implements, multiple interfaces, interface extends, Dependency Injection
trait, use, multiple traits, conflict resolution, abstract in trait — horizontal reuse
namespace, use, PSR-4, Composer autoload, third-party packages
try/catch/finally, throw, custom exceptions, exception hierarchy, global handler