You are here: Re: Confusion about classes and objects « PHP Programming Language « IT news, forums, messages
Re: Confusion about classes and objects

Posted by Toby A Inkster on 03/02/07 17:56

Iván Sánchez Ortega wrote:

> You're assigning a copy og $item to $toc_items_arr[1], not a reference to
> $item.

This is almost certainly the problem.

Note that in PHP 5 the default behaviour of the assignment operator is
changed with respect to how it operates on objects, and is closer to the
Java behaviour which is what I think you were expecting.

PHP 4:

<?php
$a = new Object();
$b = $a;
// Variables $a and $b point to two different objects.
// Changes to $a do not effect $b.
?>

PHP 5:

<?php
$a = new Object();
$b = $a;
// Variables $a and $b point to the same object.
// Changes to $a effect $b.
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

 

Navigation:

[Reply to this 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

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