Php WTF

array_combine cant combine empty arrays

var_dump(array_combine(array(), array()));

Produces:

warning: array_combine(): Both parameters should have at least 1 element in /home/daniel/hg/xmlrpc/test.php on line 6
bool(false)

String {} only works on some strings

 
$o = new stdObject();
$o->name = 'nisse';
echo ((string)($o->name)){0};
Parse error: syntax error, unexpected '{', expecting ',' or ';' in /home/daniel/www/tmp/tmp/string.php on line 8

static in a non-static function is class-scope

class fnstatic
{
    public function once ()
    {
        static $once = true;
        if ($once) {
            echo "once\n";
            $once   = false;
        } else {
            echo "no once\n";
        }
    }
}

$a = new fnstatic();
$a->once();
$b = new fnstatic();
$b->once();

Output:

once
no once
 
php/wtf.txt · Last modified: 2009/08/27 15:54 by daniel
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki