How can static class variables be emulated in PHP4 to achieve similar functionality as in PHP5?

In PHP4, static class variables can be emulated by using global variables within a class. By defining a global variable within the class and accessing it using the `global` keyword inside class methods, similar functionality to PHP5 static class variables can be achieved.

class MyClass {
    function increment() {
        global $counter;
        $counter++;
        return $counter;
    }
}

$counter = 0;

$obj1 = new MyClass();
echo $obj1->increment(); // Output: 1

$obj2 = new MyClass();
echo $obj2->increment(); // Output: 2