Web Development
0/6 sections
0%

PHP

PHP powers 77% of the web including WordPress, Laravel, and major platforms. It is a server-side scripting language designed for web development with deep database integration and a massive ecosystem.

1PHP Fundamentals

php
<?php
// Variables (weakly typed, dynamic)
$name = "Sufi";
$age = 30;
$price = 9.99;
$active = true;
$nothing = null;

// String operations echo "Hello, $name!"; // interpolation echo 'Hello, ' . $name . '!'; // concatenation echo strlen($name); // 4 echo strtoupper($name); // SUFI echo str_replace('o', '0', $name); // Sufi → Sufi echo sprintf("Price: $%.2f", $price); // Price: $9.99

// Arrays $fruits = ['apple', 'banana', 'cherry']; $person = ['name' => 'Sufi', 'age' => 30]; // associative echo $fruits[0]; // apple echo $person['name']; // Sufi echo count($fruits); // 3 array_push($fruits, 'date'); $sorted = sort($fruits); ```

2Control Flow & Functions

php
<?php
// Conditionals
if ($age >= 18) {
    echo "Adult";
} elseif ($age >= 13) {
    echo "Teen";
} else {
    echo "Child";
}

// Match expression (PHP 8+) $status = match($code) { 200 => 'OK', 404 => 'Not Found', 500 => 'Server Error', default => 'Unknown' };

// Loops foreach ($fruits as $index => $fruit) { echo "$index: $fruit "; }

// Functions function calculateTax(float $amount, float $rate = 0.15): float { return $amount * $rate; }

// Arrow functions (PHP 7.4+) $double = fn($x) => $x * 2; $doubled = array_map($double, [1, 2, 3, 4]); // [2, 4, 6, 8]

// Named arguments (PHP 8+) echo implode(separator: ', ', array: $fruits); ```

3OOP in PHP

php
<?php
abstract class Animal {
    protected string $name;
    private static int $count = 0;

public function __construct(string $name) { $this->name = $name; self::$count++; }

abstract public function speak(): string;

public static function getCount(): int { return self::$count; }

public function __toString(): string { return "Animal({$this->name})"; } }

interface Trainable { public function train(string $command): bool; }

class Dog extends Animal implements Trainable { private array $tricks = [];

public function speak(): string { return "{$this->name} says: Woof!"; }

public function train(string $command): bool { $this->tricks[] = $command; return true; } }

$dog = new Dog("Rex"); echo $dog->speak(); // Rex says: Woof! echo Animal::getCount(); // 1 ```

4Database with PDO

php
<?php
// PDO secure database abstraction
$dsn = "mysql:host=localhost;dbname=myapp;charset=utf8mb4";
$pdo = new PDO($dsn, 'username', 'password', [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES => false,
]);

// Parameterized queries prevent SQL injection $stmt = $pdo->prepare("SELECT * FROM users WHERE email = ? AND active = ?"); $stmt->execute([$email, 1]); $user = $stmt->fetch();

// Named parameters $stmt = $pdo->prepare("INSERT INTO users (name, email, role) VALUES (:name, :email, :role)"); $stmt->execute(['name' => $name, 'email' => $email, 'role' => 'user']); $newId = $pdo->lastInsertId();

// Transaction $pdo->beginTransaction(); try { $pdo->prepare("UPDATE accounts SET balance = balance - ? WHERE id = ?")->execute([$amount, $from]); $pdo->prepare("UPDATE accounts SET balance = balance + ? WHERE id = ?")->execute([$amount, $to]); $pdo->commit(); } catch (Exception $e) { $pdo->rollBack(); throw $e; } ```

5Laravel Framework

php
<?php
// Eloquent ORM
class User extends Model {
    protected $fillable = ['name', 'email', 'role'];
    protected $hidden = ['password', 'remember_token'];
    protected $casts = ['email_verified_at' => 'datetime'];

public function posts(): HasMany { return $this->hasMany(Post::class); }

public function roles(): BelongsToMany { return $this->belongsToMany(Role::class); } }

// Query builder $users = User::where('active', true) ->where('created_at', '>=', now()->subDays(30)) ->orderBy('name') ->with('posts') // eager load ->paginate(20);

// Routes (web.php) Route::get('/users', [UserController::class, 'index'])->middleware('auth'); Route::resource('/posts', PostController::class);

// Blade template // {{ $user->name }} @foreach($posts as $post) {{ $post->title }} @endforeach

// Artisan commands // php artisan make:model User -mrc (model + migration + resource controller) // php artisan migrate // php artisan queue:work ```

6Modern PHP & Security

php
<?php
// PHP 8.x features
// Union types
function process(int|string $input): int|string { ... }

// Nullsafe operator $city = $user?->address?->city;

// Fibers (PHP 8.1) cooperative multitasking $fiber = new Fiber(function(): void { $value = Fiber::suspend('first'); echo "Got: $value "; }); $first = $fiber->start(); // 'first' $fiber->resume('hello'); // Prints: Got: hello

// Security essentials password_hash($password, PASSWORD_ARGON2ID); // hash passwords password_verify($input, $hash); // verify filter_var($email, FILTER_VALIDATE_EMAIL); // validate input htmlspecialchars($output, ENT_QUOTES, 'UTF-8'); // escape output ```

Explore the Full Portfolio

This is the complete portfolio of Sufi Khan Sulaiman, a technology leader specialising in B2B commerce and digital automation. Start from the Home page for the overview, then move through two decades of career experience across FLIR Systems, Lorex Technology, and 1c Platform, and the full catalogue of project case studies spanning headless commerce migrations, AI recommendation engines, and multi-channel fulfilment systems.

The skills and certifications page maps the technical and leadership capabilities behind the work, while the articles and the knowledge base break down the thinking into actionable frameworks. For hands-on learning, the tutorials and applications sections cover practical builds from front-end fundamentals to full-stack web apps.

For consulting engagement, the expertise page outlines service offerings, the ecommerce hub covers platform architecture and automation strategy, and the ecommerce guide (PDF) is a downloadable 55-page field manual. When you are ready to talk, the contact page is the direct line.