Most of PEAR is still targeting php4, so you can use that as a "framework". I believe drupal and codeignitor are also still targeting php4 (Perhaps cakephp also?).
The biggest problem with objects and php4 is that objects are passed by-value, so you need to use references to get the usual semantics that most other languages have for objects (including php5). You have to be very careful to always assign a reference to objects. Otherwise it'll be implicitly cloned. This is tedious and very hard to debug if you mess up. Besides, it will make your code incompatible with php5. Eg.:
Creating an object:
$foo =& new Foo();
Passing an object as argument to a function:
class Bar {
function cuux(&$foo) {
}
}
$bar =& new Bar();
$bar->cuux($foo);
Since arguments are references, you can't pass a constant. So if you must pass NULL instead of an object, you have to assign NULL to a local variable first. Eg.:
$bar =& new Bar();
$foo = null;
$bar->cuux($foo);
Returning objects from a function:
class Bar {
function &doink() {
$foo =& new Foo();
return $foo;
}
}
$bar =& new Bar();
$foo =& $bar->doink();
Note that you MUST assign $foo to a variable, which makes it impossible to return the result of another function directly. Eg. this is illegal:
class Bar {
function &doink() {
return $this->foo->doink();
}
}
It should be:
class Bar {
function &doink() {
$tmp =& $this->foo->doink();
return $tmp;
}
}
Miss just one of those ampersands and you're toast. Also, make sure you have a very good understanding of how references behave - They are not exactly intuitive.