note 40627 added to functions.arguments
| From: | kieran at kieran dot ca | Date: | Wed, 10 Mar 2004 06:03:14 +0000 |
| Subject: | note 40627 added to functions.arguments | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66525@lists.php.net to get a copy of this message | ||
I was trying to pass an internal class variable as a default for a function argument inside the
class where... um.... let me clarify with code:
<?
class some_class{
var $some_variable;
function some_function($argument=$this->some_variable){
do the thing...
}
}
?>
doesn't work, throws a parse error.
Instead, I had to use:
<?
class some_class{
var $some_variable;
function some_function($argument=''){
if(!$argument){$argument = $this->some_variable;}
do the thing...
}
}
?>
So much easier to explain by example! Hope that helps someone ;-)
Cheers, Kieran
----
Manual Page -- http://www.php.net/manual/en/functions.arguments.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40627
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40627&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40627&report=yes
Search -- http://master.php.net/manage/user-notes.php