Skip to content

Instantly share code, notes, and snippets.

View daveh's full-sized avatar

Dave Hollingworth daveh

View GitHub Profile
@daveh
daveh / .env.example
Last active December 31, 2024 15:38
Configuring PHP Applications (code to accompany https://youtu.be/L5E2HSHrDjw)
DATABASE_HOSTNAME=localhost
DATABASE_USERNAME=db_username
DATABASE_PASSWORD=db_password
DATABASE_NAME=db_name
@daveh
daveh / form.php
Last active April 1, 2024 13:46
Generate QR Codes with PHP (code to accompany https://youtu.be/8xPWPGxL7Xk)
<!DOCTYPE html>
<html>
<head>
<title>Generating QR Codes with PHP</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<h1>Generating QR Codes with PHP</h1>
@daveh
daveh / form.html
Last active October 10, 2024 20:05
PHP File Uploads (code to accompany https://youtu.be/K_W5ZqwEcqs)
<!DOCTYPE html>
<html>
<head>
<title>PHP File Uploads</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<h1>PHP File Uploads</h1>
@daveh
daveh / index.html
Created September 7, 2022 16:22
Prevent favicon requests: the fastest way to stop the browser from requesting favicon.ico (code to accompany https://youtube.com/shorts/UI_yJY5jMrQ)
<link rel="icon" href="data:,">
@daveh
daveh / index.php
Created August 14, 2022 11:23
Show all errors in PHP (code to accompany https://youtube.com/shorts/K4TMD0mLOJY)
<?php
ini_set("display_errors", "1");
ini_set("display_startup_errors", "1");
error_reporting(E_ALL);
@daveh
daveh / form.html
Last active May 17, 2025 18:21
Send email with PHP (code to accompany https://youtu.be/fIYyemqKR58)
<!DOCTYPE html>
<html>
<head>
<title>Contact</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<h1>Contact</h1>
@daveh
daveh / form.html
Last active April 25, 2025 12:06
Generate a PDF with PHP (code to accompany https://youtu.be/XGS732DLtDc)
<!DOCTYPE html>
<html>
<head>
<title>PDF Example</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<h1>Example</h1>
@daveh
daveh / form.html
Last active April 16, 2025 11:30
HTML to MySQL using PHP (code to accompany https://youtu.be/Y9yE98etanU)
<!DOCTYPE html>
<html>
<head>
<title>Contact</title>
<meta charset="UTF-8">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.min.css">
</head>
<body>
@daveh
daveh / attributes.php
Created January 11, 2022 09:10
What's new in PHP 8.0 (code to accompany https://youtu.be/ve9bKHZG47c)
<?php
#[\Attribute(Attribute::TARGET_CLASS)]
class Route
{
public function __construct(
public string $path
)
{}
}
@daveh
daveh / 1-file_get_contents.php
Created August 8, 2021 15:10
How to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs (code to accompany https://youtu.be/wMyP-q3nPd4)
<?php
$payload = json_encode([
"title" => "Updated title"
]);
$options = [
"http" => [
"method" => "PATCH",
"header" => "Content-type: application/json; charset=UTF-8\r\n" .