Skip to content
Snippets

Snippet Library

Practical pure PHP patterns that are easy to study, adapt and use.

Code

Sanitize HTML Output

Escapes browser-facing text with `htmlspecialchars()` at render time so names, notes, and labels cannot become executable HTML.

Open Snippet
Code

Destroy a Session

Destroys the active PHP session, clears the session array, and expires the session cookie for logout or reset workflows.

Open Snippet
Code

Get Last Insert ID

Inserts one mission-log row with procedural mysqli, then returns the exact auto-increment ID produced by that insert.

Open Snippet