# zend guard

- Thread: https://externals.io/message/57578
- Original archive: https://news-web.php.net/php.internals/57578
- Started by Adi Mutu on 2012-01-30T16:11:51+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #57578 — Adi Mutu — 2012-01-30T16:11:51+00:00

URL: https://externals.io/message/57578#57578

Hello,

Can anybody tell me what this struct is used for ?
I'm new to the internals of php.

Thanks,
A

---

## #57579 — jpauli — 2012-01-30T16:26:38+00:00

URL: https://externals.io/message/57578#57579 · In reply to: #57578

Quickly reading the source and trying things, I suggest its a guard against
recursion in __get and __set handlers.
This way, code such this one won't infinitly loop :

class Foo {
    public function __get($p) {
        return $this->$p; // this should lead to a recursion loop
    }
}

$f = new Foo;
echo $f->barbaz;

http://lxr.php.net/opengrok/xref/PHP_5_4/Zend/zend_object_handlers.c#440
http://lxr.php.net/opengrok/xref/PHP_5_4/Zend/zend_object_handlers.c#zend_get_property_guard
http://lxr.php.net/xref/PHP_5_4/Zend/zend.h#290

Julien.P



> Hello,
>
> Can anybody tell me what this struct is used for ?
> I'm new to the internals of php.
>
> Thanks,
> A

---

## #57582 — Clint M Priest — 2012-01-30T20:47:43+00:00

URL: https://externals.io/message/57578#57582 · In reply to: #57579

That's exactly what it's used for.

-----Original Message-----
From: julienpauli@gmail.com [mailto:julienpauli@gmail.com] On Behalf Of jpauli
Sent: Monday, January 30, 2012 10:27 AM
To: Adi Mutu
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] zend guard

Quickly reading the source and trying things, I suggest its a guard against recursion in __get and __set handlers.
This way, code such this one won't infinitly loop :

class Foo {
    public function __get($p) {
        return $this->$p; // this should lead to a recursion loop
    }
}

$f = new Foo;
echo $f->barbaz;

http://lxr.php.net/opengrok/xref/PHP_5_4/Zend/zend_object_handlers.c#440
http://lxr.php.net/opengrok/xref/PHP_5_4/Zend/zend_object_handlers.c#zend_get_property_guard
http://lxr.php.net/xref/PHP_5_4/Zend/zend.h#290

Julien.P



> Hello,
>
> Can anybody tell me what this struct is used for ?
> I'm new to the internals of php.
>
> Thanks,
> A
