<p>In C++, I code this way:</p>

<pre><code>//foo.h    
class cBar
{
    void foobar();
}
</code></pre>

<hr>

<pre><code>//foo.cpp
void cBar::foobar()
{
    //Code
}
</code></pre>

<p>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?</p>

You can't really do this in the same manner.
You can use
class abstraction
and
interfaces
, though. The main difference between the two is that and interface does not allow you to specify the function body, where (not abstract) methods in an abstract object can hold all kinds of default behaviour.
Abstraction:
```
```
abstract class cBar
{
    // MUST be extended
    abstract protected function foobar();

    // MAY be extended
    protected function someMethod()
    {
        // do stuff
    }
}

class cBarExtender extends cBar
{
    protected function foobar()
    {
        // do stuff
    }

}
```
```
Interfacing:
```
```
interface cBar 
{
    // MUST be implemented
    protected function foobar();
}

class cBarImplementation implements cBar
{
    protected function foobar()
    {
        // do stuff
    }
}
```
```