THE CODE

Programming

Programming is most useful when a small, clear example helps solve a real problem. This section will grow with working PHP and JavaScript examples.

PHP · PRACTICAL TUTORIAL

How to Get the Current Page URL with PHP

Separate the requested address from the canonical address and avoid making your public hostname depend on untrusted request headers.

Explore
ARCHIVED PROJECT · GAME AI

Tic-Tac-Toe AI with Minimax and Alpha-Beta Pruning

See how a computer can choose a move by searching possible replies, then try the new browser-based teaching demo.

Explore
PHP · PRACTICAL GUIDE

Common PHP File-Path Problems and How to Fix Them

Understand why a file loads from one page but fails from another, then make the path rules explicit.

Explore
JAVASCRIPT · PRACTICAL TUTORIAL

How to Synchronize Scrolling Between Two Elements

Build a bidirectional scroll link that handles different content heights without taking over the visitor’s input.

Explore
PHP · TUTORIAL

How to Extract a Directory Name from a URL in PHP

Separate URL paths from query strings, identify category and article segments, and handle missing or unexpected values.

Explore
PHP · TUTORIAL

Build PHP Recommendations That Exclude the Current Page

Select related pages from a trusted directory, exclude the page being viewed, and handle small categories without duplicate links.

Explore
JAVASCRIPT · TUTORIAL

Replace onmouseover with JavaScript Event Listeners

Move hover behavior out of HTML, avoid child-element flicker, and support keyboard focus alongside pointer interaction.

Explore
PHP · TUTORIAL

How to Pick a Random Item from a PHP Array

Select one entry or several unique entries while handling array keys, empty lists and repeat choices.

Explore
PHP · TUTORIAL

PHP Redirects: How to Use header() Correctly

Send visitors to a new page without output errors, redirect loops or an untrusted destination.

Explore
PHP · TUTORIAL

Read a Text File Line by Line

Choose between file() and fgets(), with practical path and blank-line checks.

Explore
PHP · PROJECT

Build an Item of the Day

Match each physical line in a file to a calendar day with a defined time zone.

Explore
JAVASCRIPT · TUTORIAL

Replace Inline onclick

Use addEventListener() with accessible buttons, event options and cleanup.

Explore
PRACTICAL TOOL

URL Encoder & Decoder

See how URL components are encoded and decoded in the browser.

Explore
PRACTICAL TOOL

Meta Description Counter

Measure text length as you prepare page metadata.

Explore