Date: 09/15/01
- Next message: Andi Gutmans: "Re: [PHP-DEV] zend_do_end_class_declaration() question"
- Previous message: mike: "Re: [PHP-DEV] Bug #13309 Updated: apache won't start, no errors in any log files, php.ini problem?]"
- In reply to: php <email protected>: "[PHP-DEV] Bug #13315: problem with function definitions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 13315
Updated by: hholzgra
Reported By: php <email protected>
Status: Bogus
Bug Type: *General Issues
Operating System: WIN98/APACHE1.3.19
PHP Version: 4.0.4pl1
New Comment:
no way, default values are evaluated at compile time
and there is no $foo set at all as the program didn't
start to run by that time
what you want to do is something like
function showvar ( $bar = NULL ) {
if ( $bar === NULL ) {
$bar = $GLOBALS['foo'];
}
echo $bar;
}
Previous Comments:
------------------------------------------------------------------------
[2001-09-15 05:43:00] php <email protected>
why is that? I really need this:(
Will a later version of php support constructions like this?
------------------------------------------------------------------------
[2001-09-15 05:28:13] mfischer <email protected>
Shouldn't. Default values must be constant expressions.
Not a bug, bogusified.
- Markus
------------------------------------------------------------------------
[2001-09-15 05:11:56] php <email protected>
<?php
$foo = 'foo';
function showvar( $bar = $foo )
{
//global $foo
//doesn't work either
echo $bar;
}
showvar();
showvar('bar');
?>
gives me a parse error on line 3:(
also:
<?php
$foo = 'foo';
function returnvar()
{
global $foo;
return $foo;
}
function whatisvar( $bar = returnvar() )
{
echo $bar;
}
?>
gives me this:
Parse error: parse error, expecting `')'' in c:/path/to/script/test.php on line 9
Should work, shouldn't it?
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=13315&edit=1
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Andi Gutmans: "Re: [PHP-DEV] zend_do_end_class_declaration() question"
- Previous message: mike: "Re: [PHP-DEV] Bug #13309 Updated: apache won't start, no errors in any log files, php.ini problem?]"
- In reply to: php <email protected>: "[PHP-DEV] Bug #13315: problem with function definitions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

