Abstracts in PHP4
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Abstracts in PHP4
I'm writing a class for public use, so I'd like to give a PHP4 version as well. However, the abstract has an abstract function... How do I show this through PHP4?
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
If you're going to do that, you may as well provide it for them.
Generally I create a dummy class for PHP 4 with either empty or trigger_error() filled methods.
Generally I create a dummy class for PHP 4 with either empty or trigger_error() filled methods.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Horrible, but:
Code: Select all
/* abstract */ class MyAbstract {
/* abstract */ function myFunction () {
trigger_error("Abstract function MyAbstract::myFunction not declared.", E_USER_ERROR);
}
}(#10850)
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
arborint wrote:Horrible, but:Code: Select all
/* abstract */ class MyAbstract { /* abstract */ function myFunction () { trigger_error("Abstract function MyAbstract::myFunction not declared.", E_USER_ERROR); } }
I like that approach. Thanks for that.
You can also use docblocks which is handy since IDE's can also catch it
Code: Select all
/**
* My class is cool
*
* @abstract
*/
class MyAbstractClass
{
}- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: