note 112323 deleted from language.references.pass by danbrown
| From: | danbrown@php.net | Date: | Wed, 05 Jun 2013 17:38:52 +0000 |
| Subject: | note 112323 deleted from language.references.pass by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195059@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Function arguments involving references is following the trait of the C language.
For those who knows the C language, the following example should shed some light on the behavior of
PHP.
struct _A {
int value;
};
void change_reference (struct _A* a)
{
a->value = 4;
a = malloc(sizeof(struct _A)); // a becomes a local variable
a->value = 5;
}
main ()
{
struct _A* A = malloc(sizeof(struct _A));
A->value = 2;
change_reference (A);
printf("%d", A->value); // echo 4 (not 5)
}