Skip to content

Instantly share code, notes, and snippets.

View clytras's full-sized avatar

Christos Lytras clytras

View GitHub Profile
@clytras
clytras / PhpArrayToYaml.php
Created February 19, 2021 10:18 — forked from ArnaudLigny/PhpArrayToYaml.php
Convert PHP array to YAML
#!/usr/local/bin/php
<?php
if (php_sapi_name() !== 'cli') {
return;
}
date_default_timezone_set('Europe/Paris');
require_once 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
try {
void MyFunc()
{
short int one = 1,
two = 2,
three = 3,
myBigFatVariableName = 0,
anOtherBigFatVariableName = 1;
if (
!myBigFatVariableName ||
@clytras
clytras / php-event-listener-example.php
Created November 21, 2021 02:35 — forked from im4aLL/php-event-listener-example.php
PHP event listener simple example
<?php
// Used in https://github.com/im4aLL/roolith-event
class Event {
private static $events = [];
public static function listen($name, $callback) {
self::$events[$name][] = $callback;
}

PHP Token names with values

This is a list of all PHP 8.0 tokens and their represented values in decimal and hexadecimal. The list exists in the php.net site here https://www.php.net/manual/en/tokens.php but there are no values because these values may change for new releases. When writing token parsing code, we need token names and values, and I don't want to dig into the source code to get the values.

Beware that many, if not all values, may be different along version; PHP 7 may not have the same values with PHP 8. Always use the constants, this is just for reference mainly for debugging.

Blog link https://lytrax.io/blog/dev/php-tokens