Jump to content

constant and class problem


ComGuar

Recommended Posts

Humm...

 

first, I would probably move my constants to a file outside the class and include them in the script in order to keep all constants in one location.

 

You have a high-level of restriction set on the sample code.. final classes are the end of the line, and can't be overridden or extended. Maybe not the best choice, but it all depends on your implementation

 

The use of OOP is to create widely reusable code that is usable in various projects.. declaring a filepath inside a class is not well-advised.

 

 

i suggest :

 

class myClass{
  // properties
  protected $_directory;
  // construct (used to pass attributes to the class)
  public function __construct($directory){
     $this->_directory = $directory
  }
}

 

This way, the directory used by this class can be called at runtime using

 

// instantiate the object
$object = new myClass(MY_DIR_CONSTANT);

 

And then you can work on that. I'd recommend grabbing an OOP book if none of this makes any sense. Let me know if you have any problems

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.