Reply to Re: [PHP] Re: Strange notation to create object

Your name:

Reply:


Posted by Robert Cummings on 11/09/08 11:19

On Thu, 2005-06-23 at 13:36, Matthew Weier O'Phinney wrote:
> * Robert Cummings <robert@interjinn.com> :
> > On Thu, 2005-06-23 at 11:32, Matthew Weier O'Phinney wrote:
> > > The above notation is unnecessary when developing in PHP5, as objects in
> > > PHP5 are passed by reference by default. However, in PHP4, this was
> >
> > Not entirely, there's still a subtle difference in PHP5 between
> > assigning an object with = versus assigning with = &.
>
> Would you mind explaining the difference? I've seen nothing in the docs,
> to indicate that assigning objects with =& in PHP5 is necessary, or even
> desired. My experience with PHP5 hasn't shown this either. I'd be
> interested to know to what you refer.

See for yourself when running the following script:

<?php

class a
{
}

class b
{
}

$aObj = new a();
$bObj = new b();

$foo1 = $aObj;
$foo2 = $aObj;
$foo3 = $foo1;
$foo4 = &$foo2;

echo "------------------\n";
print_r( $foo1 );
print_r( $foo2 );
print_r( $foo3 );
print_r( $foo4 );

$foo1 = $bObj;
$foo2 = $bObj;

echo "------------------\n";
print_r( $foo1 );
print_r( $foo2 );
print_r( $foo3 );
print_r( $foo4 );

$foo1 = &$aObj;
?>

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация