[thelist] OO PHP call a method on class when instantiated

Simon Perry thelist at si-designs.co.uk
Wed Jun 15 06:04:16 CDT 2005


Dan Romanchik wrote:

> These are called constructors.  Read
>
>
> http://www.phpbuilder.com/manual/language.oop.constructor.php
>
> for an explanation of how they work.
>
Dan,

I new there was something simple I was missing! I now have a function 
with the same name as my class that gets called when a new instance of 
the class is made.

// sudo code
class MyClass
  {
  var $foo;

  function MyClass
    {
     $this->foo='bar';
     }
  }

Thanks

Simon


More information about the thelist mailing list