php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6566 Function default argmnt. doesn't accept variable
Submitted: 2000-09-05 23:28 UTC Modified: 2000-09-05 23:51 UTC
From: amri at easternaura dot com Assigned:
Status: Closed Package: Variables related
PHP Version: 4.0.2 OS: Redhat Linux 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
40 - 37 = ?
Subscribe to this entry?

 
 [2000-09-05 23:28 UTC] amri at easternaura dot com
Default function argument doesn't accept variable. 

function echoname ($name = 'bob') 
works fine but

$him = 'bob';
function echoname ($name = $bob)
will produce error.

I'm not sure either this is a bug or limitation but I guess its useful if variable is allowed as default function argument.

regards,
amri

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-05 23:31 UTC] amri at easternaura dot com
Default function argument doesn't accept variable. 

function echoname ($name = 'bob') 
works fine but

$bob = 'bob';
function echoname ($name = $bob)
will produce error.

I'm not sure either this is a bug or limitation but I guess its useful if variable is
allowed as default function argument.

regards,
amri

 [2000-09-05 23:50 UTC] sterling@php.net
Documented incompatibility between PHP3 & PHP4, probably will not change.
 [2000-09-05 23:51 UTC] sterling@php.net
Forgot to close.
 [2003-01-10 11:22 UTC] misc at instantmassacre dot com
Still apparant in PHP 4.2.3 and 4.3.0

As stated this behaviour is documented and will not change. Why is this?

Would Incompatibility with PHP3, being it only the minority of PHP servers are still running PHP3, be the issue?
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Oct 19 10:01:26 2019 UTC