Re: Static method to get class variable (PHP4)
- From: no@email
- Date: Wed, 31 May 2006 17:23:05 +0200
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;
}
.
- Prev by Date: Re: preg_match and delimited strings
- Next by Date: Re: Different binary results with different PHP versions
- Previous by thread: <<< State of the art web solution Online>>>
- Next by thread: pear all packages for offline use
- Index(es):