コード例 #1
0
    function logMethodStart()
    {
        $trace = debug_backtrace();
        //var_dump($trace);
        $method = '';
        if (count($trace) > 1) {
            $data = $trace[1];
            if (!empty($data['class'])) {
                $method .= $data['class'] . '::';
            }
            $method .= $data['function'];
        }
        echo "Method = \"" . $method . "\"";
        echo "\n";
    }
}
class Outer extends Base
{
    function mytest()
    {
        $this->logMethodStart();
    }
}
function functest()
{
    Base::logMethodStart();
}
$o = new Outer();
$o->mytest();
functest();
Base::logMethodStart();
コード例 #2
0
ファイル: 004.php プロジェクト: badlamer/hhvm
    public function __construct($data)
    {
        $this->data = $data;
    }
    public function getArrayAccess()
    {
        /* create a proxy object implementing array access */
        return new class($this->data) extends Outer implements ArrayAccess
        {
            public function offsetGet($offset)
            {
                return $this->data[$offset];
            }
            public function offsetSet($offset, $data)
            {
                return $this->data[$offset] = $data;
            }
            public function offsetUnset($offset)
            {
                unset($this->data[$offset]);
            }
            public function offsetExists($offset)
            {
                return isset($this->data[$offset]);
            }
        };
    }
}
$outer = new Outer(array(rand(1, 100)));
/* not null because inheritance */
var_dump($outer->getArrayAccess()[0]);
コード例 #3
0
ファイル: outer.php プロジェクト: nloadholtes/people-prodigy
        $filecontent = preg_replace("/<{interappraisal_start}>(.*?)<{interappraisal_end}>/s", "", $filecontent);
        $pos = "select position from {$user_table} where user_id='{$user_id}'";
        $posres = $db_object->get_a_line($pos);
        $position = $posres['position'];
        $pattern = "/<!--performance_start-->(.*?)<!--performance_end-->/s";
        preg_match($pattern, $file, $arr);
        $match = $arr[0];
        if ($position == 0) {
            $xTemplate = preg_replace($pattern, "", $xTemplate);
        }
        $temp_user_table = $common->prefix_table("temp_user_table");
        $user_table = $common->prefix_table("user_table");
        $selqry = "select user_id from {$temp_user_table}";
        //	echo $selqry;
        $temp_ids = $db_object->get_single_column($selqry);
        $ids = @implode(",", $temp_ids);
        if ($ids) {
            $selqry = "select admin_id from {$user_table} where user_id in ({$ids})";
            $adminids = $db_object->get_single_column($selqry);
        }
        if (!@in_array($user_id, $adminids)) {
            $xTemplate = preg_replace("/<!--alertforempupdate-->(.*?)<!--alertforempupdate-->/s", "", $xTemplate);
        }
        $values = array();
        $xTemplate = $common->direct_replace($db_object, $xTemplate, $values);
        echo $xTemplate;
    }
}
$otrobj = new Outer();
$otrobj->display($common, $db_object, $user_id);
include "footer.php";
コード例 #4
0
ファイル: 005.php プロジェクト: badlamer/hhvm
    }
    public function getArrayAccess()
    {
        /* create a child object implementing array access */
        /* this grants you access to protected methods and members */
        return new class($this->data) implements ArrayAccess
        {
            public function offsetGet($offset)
            {
                return $this->data[$offset];
            }
            public function offsetSet($offset, $data)
            {
                return $this->data[$offset] = $data;
            }
            public function offsetUnset($offset)
            {
                unset($this->data[$offset]);
            }
            public function offsetExists($offset)
            {
                return isset($this->data[$offset]);
            }
        };
    }
}
$data = array(rand(1, 100), rand(2, 200));
$outer = new Outer($data);
$proxy = $outer->getArrayAccess();
/* null because no inheritance, so no access to protected member */
var_dump(@$outer->getArrayAccess()[0]);