Basic cURL GET Request
Sends a GET request with cURL, requires HTTPS, captures HTTP status, and avoids dumping transport errors to users.
Open SnippetPractical pure PHP patterns that are easy to study, adapt and use.
Sends a GET request with cURL, requires HTTPS, captures HTTP status, and avoids dumping transport errors to users.
Open SnippetPosts a JSON payload with cURL, validates HTTPS, sets JSON headers, and returns decoded response data when possible.
Open SnippetReads a client IP address safely from server data and only trusts forwarded headers when explicitly allowed.
Open SnippetChecks whether a relative file exists under an approved base directory and rejects traversal-style paths.
Open SnippetCreates a relative directory beneath an approved base path, validates the directory name, and reports whether it was created or already existed.
Open SnippetLists regular files from an approved directory, skips dot entries, and optionally filters by extension.
Open SnippetExtracts and normalizes a file extension from a filename, then checks it against an approved extension list.
Open SnippetValidates one uploaded file, builds a collision-resistant filename, and moves it into an approved upload directory.
Open SnippetParses an XML string with SimpleXML, reports parsing errors, and extracts selected child values into an array.
Open SnippetCreates a modern PHP password hash with password_hash() after enforcing a practical minimum password length.
Open SnippetVerifies a submitted password against a stored PHP password hash and reports whether the hash should be upgraded.
Open SnippetEncodes a string with base64_encode(), decodes it with strict base64_decode(), and confirms the round trip.
Open Snippet