Пример #1
0
function fffuntainted()
{
    //ERROR: this just doesnt work, refs to globals are returned with ref semantics
    //    $r=&fchooser(33);
    //    $r=$r+33;
    //    echo "local \$r is $r\n";
    global $wpdb, $dummy;
    $v = 12;
    ffftainted($v);
    //error 1-solved
    echo "reference var: {$v}\n";
    $wpdb->print_me();
    $wpdb = new wpdb();
    $wpdb->v = 122;
    return $wpdb->v;
    //error 2 -solved
}
Пример #2
0
    $s = "hello";
    $o->fref($s)->fref($s)->fref($s);
    $o->fref($s)->fref($s);
    $o->fref($s);
    $o->fref($s, " from nick");
    echo "Call-by-ref in an object method: {$s}\n";
}
function fffuntainted()
{
    $o = new ctainted();
    $s = "hello";
    $o->fref($s)->fref($s)->fref($s);
    $o->fref($s)->fref($s);
    $o->fref($s);
    $o->fref($s, " from nick");
    echo "Call-by-ref in an object method: {$s}\n";
    $o = new cuntainted();
    $s = "hello";
    $o->fref($s)->fref($s)->fref($s);
    $o->fref($s)->fref($s);
    $o->fref($s);
    $o->fref($s, " from nick");
    echo "Call-by-ref in an object method: {$s}\n";
}
ffftainted();
fffuntainted();
//Returning a reference of a method prototype does not work,
//returns by value. This is due to call_user_func_array().
//$v=&$o->gref(77);
//$o->v1=99;
//echo "return-by-ref in an object method: $v\n";