Jump to content

gather classes together


xploita

Recommended Posts

hello,

using php4

i'm having a problem gathering all my classes together.i have three classes(ErrorHandler,i18n and templateEngine),placed in separate files.

should i create one class and inherit from it or what?

another thing,the following example is not working.any ideas why not?

<?php
class A
{
    var $name = "name";
    function getname()
    {
       return $this->name;
    }
}

class B 
{
    function bar()
    {
	$name = A::getname();
	echo $name;
    }
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/45918-gather-classes-together/
Share on other sites

You are calling the method from a static context.  You need to instantiate the object like this:

 

<?php
class A
{
    var $name = "name";
    function getname()
    {
       return $this->name;
    }
}

class B 
{
    function bar()
    {
	$a = new A();
                $name = $a->getname();
	echo $name;
    }
}
?>

 

Best,

 

Patrick

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.