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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC