- version_compare: documentation ( source)
- print_r: documentation ( source)
<?php
class Papa {
public function __construct() {
$args = func_get_args();
echo print_r($args, true);
}
}
class Kiddo extends Papa {
public function __construct() {
$args = func_get_args();
$parent_class = 'parent';
if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
$parent_class = parent::class;
}
call_user_func_array(array($parent_class, '__construct'), $args);
}
}
$x = new Papa('bee');
$y = new Kiddo('hello', 'me');