Skip to content

Instantly share code, notes, and snippets.

@hikari-no-yume
Created December 23, 2014 02:49
Show Gist options
  • Save hikari-no-yume/25042f1da1e5ba54cf6f to your computer and use it in GitHub Desktop.
Save hikari-no-yume/25042f1da1e5ba54cf6f to your computer and use it in GitHub Desktop.
Const autoloading (ab)uses
<?php
// make barewords legal!
$foo = bar . qux . boo; // no notices
use bareword as b;
$qux = b\baz;
// make barewords *illegal*!
$foo = bar; // error!
// generate escapes on-the-fly! (https://github.com/TazeTSchnitzel/escapes)
$foo = 'hello, world' . \n;
// paths!
use const path\foo\bar\baz as p; // ['foo', 'bar', 'baz']
// add a new kind of numeric literal!
$n = TRI1201111012; // int(33890)
// implement a brainfuck interpreter!
$f = plus_plus_plus_plus_plus_plus_plus_dot;
// THE ONLY LIMIT IS YOUR IMAGINATION!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment