You are here: Re: Problem retrieving an object from an array and calling a method on the object « PHP Programming Language « IT news, forums, messages
Re: Problem retrieving an object from an array and calling a method on the object

Posted by C. on 10/08/06 09:34

Jayman777@gmail.com wrote:
>
> $this->array_of_days = array();
> for ($i = 1; $i < num_days_in_month + 1; $i++)
> {
> $this->array_of_days[$i] = new Day(mktime(00, 00, 00, $in_date['mon'],
> $i, $in_date['year']));
> }
> /* Unrelated code */
> $day_object = $this->array_of_days[$index];
> $day_object->addEvent($event);
>

It's kind of weird in PHP4 - even though objects are passed as copies
by default, arrays only seem to hold references. You could explicitly
assign a reference to the variable but unless you've got a good reason
to create another reference to the object, just use the one youv'e got
already:

$this->array_of_days[$index]->addEvent($event);

C.

 

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

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