In C++, I code this way:
//foo.h
class cBar
{
void foobar();
}
//foo.cpp
void cBar::foobar()
{
//Code
}
I tried to do this on PHP but the parser would complain. PHP's documentation also doesn't help. Can this be done in PHP?
No. You need to including all your function definitions inside the class block. If defining your functions in a separate structure makes you feel better you could use an interface.
interface iBar
{
function foobar();
}
class cBar implements iBar
{
function foobar()
{
//Code
}
}
I'd suggest just getting used to coding in a new way. It's easy to code consistantly within a single language, but I think you are fighting a loosing battle if you want to do the same across languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With