Variables and References Article

variables-article-cover.jpg

A week ago PHP 4.4.0rc1 was released - this release addresses major problems with references in PHP. But not many people are fully aware of how variables and references actually work in PHP. This is where my latest article in PHP Architect comes into play. It explains in details how assigning variables, passing variables to functions and returning variables from functions work - both by-value and by-reference.

Comments

Thanx for the article, it gives a deep insight into PHP internals.

However, there's one issue left unspoken, that is PHP5 objects internal model. It's obvious they're not just variables...

How are they implemented actually?

Consider the following lines in PHP5:

$a = new Foo(); $b = $a;

Is it equivalent internally in PHP5 to this:

$a = new Foo(); $b =& $a;

If not what the difference? Is it actually "healthy" to use & with objects in PHP5? Is there speed overhead?

I'm asking all these questions because we're using PHP5 with applications which were written solely for PHP4 yet using OOP. These applications use & almost everywhere and i wonder how PHP5 treats it internally....

Add Comment

Name:
Email:

Will not be posted. Please leave empty instead of filling in garbage though!
Comment:

Please follow the reStructured Text format. Do not use the comment form to report issues in software, use the relevant issue tracker. I will not answer them here.


All comments are moderated

Life Line