Reply to Re: Static method to get class variable (PHP4)

Your name:

Reply:


Posted by no on 05/31/06 15:23

Sjoerd wrote:
> Markus Ernst wrote:
>> In order to make static class variables accessible in a clean way I try
>> to write a method in the base class, as shown in this example:
>
> You probably mean private/protected instead of static.
>
>> <?php
>> class childclass
>> {
>> var $types = array('text', 'password', 'hidden');
>> function get_types() {
>> return $types;
>> }
>> }
>>
>> print_r(childclass::get_types());
>> ?>
>
> The variable $types does not exist until an instance of this class is
> made:
>
> $foo = new childclass();
> $foo->get_types();
>

anyway, the code from above will still not work until you change
function to return:

function get_types() {
return $this -> types;
}

[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

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