note 47974 added to function.func-get-arg
| From: | mwattolanfeardottocom at osu1 dot php dot net | Date: | Tue, 07 Dec 2004 22:56:01 +0000 |
| Subject: | note 47974 added to function.func-get-arg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81500@lists.php.net to get a copy of this message | ||
func_get_arg() does not appear to be allowed to be used as a function argument itself within class
constructors in PHP 5.0.2 (wonk-ay!!!):
<?php
class ABC
{
function __construct()
{
foreach (func_get_args() as $name => $value)
{
echo <<<EOT
<br/>
$name : $value <br/>
<br/>
EOT;
}
}
}
class DEF extends ABC
{
function __construct()
{
parent::__construct(func_get_arg(0),
func_get_arg(1),
func_get_arg(2));
}
}
$def = new DEF(123123, "asdfasdf", "blahblahblah");
?>
The above script generates:
Fatal error: func_get_arg(): Can't be used as a function parameter in
c:\Inetpub\wwwroot\phpwasrc\chapter10\xxx.php on line 23
There are, however, no problems when passing these as parameters to regular functions.
----
Manual Page -- http://www.php.net/manual/en/function.func-get-arg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47974
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47974&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47974&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47974&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47974&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47974&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47974&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47974&report=yes
Search -- http://master.php.net/manage/user-notes.php