PHP Obfuscated Code
Obfuscating code is the process of disguising a program's true purpose, making the code inhibitively hard for humans to understand or designing source code to visually represent something such as a maze.
Some languages, such as Perl lend themselves very well to obfuscation because of their flexible syntax or obscure naming schemes.
PHP doesn't particularly lend itself to obfuscation but it can be abused enough to create some very confusing, but perfectly legal examples.
The three-line smiley
The following code, formatted into three lines will output a simple smiley.
$_='ca';${$_{1}}=8;${$_{0}}=chr(ord($_)-1);$_;${${$_{0}}{0}}=
ord('l')-100;$c{0}=chr(116>>$b-7);7*$_;$a<<=($b%8==0);$_;$c.=
chr((2<<2<<($b>>2)<<2>>2)+13).chr(-7+(-$b+2*$a<<1));echo $c ;
Will simply output:
:-)
<< Number One >>
The following code uses define to create constants made up of only _.
define( '_', define('__',1) + define('___', define( '____', __ ) + 2) );
echo _<<__<<___<<__>>____<<__>>___>>__>>_;
Outputs:
1


