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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: amri at easternaura dot com
New email:
PHP Version: OS:

 

 [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: Mon Oct 14 08:01:26 2019 UTC