php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26693 parse error : function funcname($val = $_SERVER['REQUEST_URI'])
Submitted: 2003-12-22 09:38 UTC Modified: 2003-12-22 09:46 UTC
From: crucifyer at korea dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.3.4 OS: Gentoo Linux 1.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: crucifyer at korea dot com
New email:
PHP Version: OS:

 

 [2003-12-22 09:38 UTC] crucifyer at korea dot com
Description:
------------
parse error in function's default value.
thanks.

Reproduce code:
---------------
class LinkManager
{
	var $uri, $flag;

	function LinkManager($uri = $_SERVER['REQUEST_URI']) // this line bug. $uri = '' is ok. $uri = $_ is error. why not?
	{
		$this->uri = $uri;
		if(strpos($uri, '?'))
			$this->flag = '&';
		else
			$this->flag = '?';
		return TRUE;
	}
}

Actual result:
--------------
active code.

class LinkManager
{
	var $uri, $flag;

	function LinkManager($uri = '')
	{
		if($uri == '')
			$this->uri = $_SERVER['REQUEST_URI'];
		else
			$this->uri = $uri;
		if(strpos($uri, '?'))
			$this->flag = '&';
		else
			$this->flag = '?';
		return TRUE;
	}
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-22 09:46 UTC] vrana@php.net
http://www.php.net/manual/en/functions.arguments.php say: "The default value must be a constant expression, not (for example) a variable, a class member or a function call."

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 30 17:01:30 2024 UTC