Skip to content

Instantly share code, notes, and snippets.

@DaveDevYT
DaveDevYT / singleton-exercise.php
Created December 21, 2021 14:44
Singleton exercise
<?php
class SingletonClass
{
private static ?SingletonClass $instance = null;
private int $counter;
private function __construct()
{
$this->counter = 0;
<?php
echo '<h3>Family Tree Exercise</h3>';
$family8 = ['member1' => 'Aethelflaed', 'member2' => '???', 'offspring' => []];
$family7 = ['member1' => 'Edward', 'member2' => '???', 'offspring' => []];
$family6 = ['member1' => 'Aethelwold', 'member2' => '???', 'offspring' => []];
$family5 = ['member1' => 'Athelstan', 'member2' => '???', 'offspring' => []];
$family4 = ['member1' => 'Alfred', 'member2' => 'Ealswith', 'offspring' => [$family7, $family8]];
$family3 = ['member1' => 'Aethelred', 'member2' => 'Wulfthryth', 'offspring' => [$family6]];
$family2 = ['member1' => 'Aethelwulf', 'member2' => 'Osburga', 'offspring' => [$family3, $family4, $family5]];
$family1 = ['member1' => 'Egbert', 'member2' => 'Redburga', 'offspring' => [$family2]];
@DaveDevYT
DaveDevYT / exercise-2.php
Created November 22, 2021 10:57
Loops exercise
<?php
echo '<h2>Exercise</h2>';
$monday = ['Soup' => 3, 'Ramen' => 5, 'Burger' => 10];
$tuesday = ['Burger' => 5, 'Waffle' => 10, 'Pizza' => 10];
$wednesday = ['Sandwich' => 5, 'Hotdog' => 7, 'Ramen' => 10];
$thursday = ['Ramen' => 5, 'Pizza' => 7, 'Soup' => 10];
$friday = [];
$weekExpenses =
@DaveDevYT
DaveDevYT / exercise.php
Last active November 15, 2021 10:54
Conditions and if else statements Exercise
<?php
$currentKeys = 2;
$maxKeyCapacity = 2;
$currentPotions = 4;
$maxPotionCapacity = 5;
$currentInventoryCapacity = $currentKeys + $currentPotions;
$maxInventoryCapacity = 10;
// New item incoming
$newItemType = 'potion';
@DaveDevYT
DaveDevYT / php.ini
Created October 28, 2021 21:00
php.ini configuration for adding XDebug
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
xdebug.mode = debug
xdebug.stopOnEntry = true
xdebug.start_with_request = yes
xdebug.client_host = "127.0.0.1"
xdebug.client_port = 9000
@DaveDevYT
DaveDevYT / httpd-vhosts.conf
Last active April 23, 2023 03:38
Apache Virtual Host Configuration
<VirtualHost dev.example.com:80>
ServerName dev.example.com
DocumentRoot "C:/xampp/htdocs/dev.example.com/public"
<Directory "C:/xampp/htdocs/dev.example.com/public">
Require all granted
AllowOverride All
</Directory>
ErrorLog "logs/dev.example.com-error.log"
CustomLog "logs/dev.example.com-access.log" combined