Jump to content

Which way is Better? OOP


JREAM

Recommended Posts

// way 1... (But im not sure how I can hold the errors inside the Blah class) everytime an item is called
class Blah {
public function __construct()
{
	$this->slice = new Slice();
	$this->thumb = new Thumb();
}
}

$blah = new Blah();
$blah->slice->file('test.jpg');

// Way 2
class Blah {

public function __construct()
{
	$this->_slice = new Slice();
	$this->_thumb = new Thumb();
}

public function slice($arg)
{
	$this->_slice->{$arg[0]}($arg[1])
}

public function thumb($arg)
{
	$this->_thumb->{$arg[0]}($arg[1])
}

}

$blah = new Blah();
$blah->slice('file', 'test.jpg');

 

Link to comment
https://forums.phpfreaks.com/topic/236803-which-way-is-better-oop/
Share on other sites

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.