Hello World
Outputs a simple Hello World message and shows the safe difference between plain text output and browser-rendered HTML output.
Open SnippetPractical pure PHP patterns that are easy to study, adapt and use.
Outputs a simple Hello World message and shows the safe difference between plain text output and browser-rendered HTML output.
Open SnippetCreates the current date and time with an explicit timezone, then returns common display, ISO 8601, and Unix timestamp formats.
Open SnippetConnects to MySQL with procedural mysqli_connect(), sets utf8mb4, returns a connection handle on success, and reports safe public failure messages.
Open SnippetFetches rows from MySQL with procedural `mysqli_*`, a prepared `SELECT`, explicit bind/result checks, and an array result for rendering.
Open SnippetFetches one published MySQL row by slug with a procedural mysqli prepared statement and returns a structured result for controller display logic.
Open SnippetRuns a procedural mysqli prepared statement with explicit bind, execute, result handling, and no string-concatenated user input in SQL.
Open SnippetReads a file with `file_get_contents()` after resolving it against an approved base directory and rejecting traversal attempts.
Open SnippetWrites text to a file with `file_put_contents()` after validating the filename, approved directory, lock flag, and byte count.
Open SnippetCreates a small reusable PHP function with typed parameters, explicit validation, predictable return data, and a clear example call.
Open SnippetChecks whether an integer is even or odd using modulo after validating numeric input and returning a structured result.
Open SnippetLoops through an indexed array with `foreach`, normalizes each ship record, and returns numbered display rows without assuming every element is valid.
Open SnippetGenerates cryptographically secure random integers with `random_int()`, validates the requested range, and formats a short verification code.
Open Snippet