> -----Original Message-----
> From: Ralph Deffke [mailto:ralph_def...@yahoo.de]
> Sent: 03 August 2009 02:41
>
> problem:
>
> __ construct( $something ... variable argument list ){
> parent::__construct( ??? );
> }
>
> I tried with func_get_args, but the problem is that it gives an
> indexed
> array back.
>
> lets say the argument list is mixed like this:
> ( "string", "string", array)
>
> func_get_args will give this
> [0] => "string"
> [1] => "string"
> [2] => array
>
> the parent constructor works also with the func:_get_args function
> in ordfer
> to handle variable argument lists
>
> if u pass the array from func_get_args the parent constructor will
> reveive
> after his func_get_args the following
>
> array( [0] => array( [0] => "string" [1] =>"string" [2] => array(
> ....)
>
> ok no problem so far. I thought just strip the key column of the
> array with
> a function like this
>
> function stripFirstColumn( $_fromThisArray ){
> $b = "";
> $_b = array();
> foreach( $_fromThisArray as $value){
> if( !is_array($value) ){
> if( empty( $b )){
> $b = $value;
> // $_b[$b]="";
> } else {
> $_b[$b]=$value;
> $b = "";
> }
> } else {
> array_push($_b, $value); or $_b[] = $value;
> }
> }
> return $_b;
> }
>
> BUT this results in an arry like this
>
> array( "string", "string", [0] => array( ...))
Advertising
I may be missing something completely here, but aren't you just looking for
$stripped_array = $_fromThisArray[0];
Even if you have to invent a "dummy" real__construct method in the parent class
to call from the extended classes, and then relay the parent __construct into
it; something like:
class parent_class {
function __construct( $something ... variable argument list ){
real__construct(func_get_args());
}
protected function real__construct() {
$args = func_get_args();
$args = $args[0];
....
}
}
class extended_class extends parent_class {
function __construct() {
parent::real__construct(func_get_args());
}
}
Disclaimer: this is all off the top of my head before morning coffee, and
completely untested. Someone else will quite likely come up with a much better
way to do this, as OOP is not really my forte... ;) ;)
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,
Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php