PHPaggregateIn PHP4, we have
class Child extends Parent1 {
var $constructor = true;
function Child() {
if (function_exists('aggregate')) {
aggregate($this, 'Parent2');
Parent2::Parent2($constructorArgs...);
}
else {
$this->parent2 = new Parent2($constructorArgs...);
}
$this->constructor = false;
}
function __call($methodName, $args) {
if (method_exists($this->parent2, $methodName)) {
call_user_func_array(array($this->parent2,$methodName), $args);
}
}
function __set($name, $val) {
if ($this->constructor) {
$this->{$name} = $val;
}
else {
if (isset($this->parent2)) {
$this->parent2->{$name} = $val;
}
}
}
function __get($name) {
if (!$this->constructor) {
return $this->parent2->{$name};
}
}
/** Everything else ... **/
}
Simple, huh? (I haven't even generalised to multiple parents.) Ironically, this can't be made any simpler because there are no mixins, and class definitions aren't treated like procedural code . . . this kind of thing is enough to make me long for lisp. This kind of thing can be gotten around with the OTOH, if someone knows of a simpler way, let me know. Pass by pointer in argumentsIn PHP 5, objects are passed by pointer rather than passing a copy (as was done in PHP 4). However, arrays are still passed by copy. Even (of course) if they are big multidimensional or associative arrays. Which is a shame, since I much prefer arrays/hashes for data. In fact, I'd prefer them for objects too, if that were syntactically feasible. Cookies
Note that comma, space and tab are three of the invalid characters. IE, Firefox and Opera work fine with these characters, and PHP reads cookies containing them fine as well. However, if you want to use these characters in cookies that you set from php, you need to use header(). |