php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13505 Reserved words can be used as constant names
Submitted: 2001-10-02 00:05 UTC Modified: 2001-10-02 06:44 UTC
From: carlfox at netdoor dot com Assigned: zak (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.6 OS: All
Private report: No CVE-ID: None
 [2001-10-02 00:05 UTC] carlfox at netdoor dot com
###########################################################
# POP UP MENU SUB ROUTINE (Condition)

function display_column_g ($label, $row, $col_name, $editable)
{
print ("<TR>\n");
printf ("<TD><B><font color=\"red\">%s</font></B></TD>\n", htmlspecialchars ($label));
$value = htmlspecialchars ($row[$col_name]);

if ($editable)	# display as edit field
{

$str = sprintf ("<SELECT NAME=\"row[%s]\">",$col_name);
$str .= sprintf ("<OPTION VALUE=\"$row[Condition]\">$row[Condition]\n", $row[Condition]);
$str .= sprintf ("<OPTION VALUE=\"\">\n");
$str .= sprintf ("<OPTION VALUE=\"New With Warranty\">New With Warranty\n", New_With_Warranty);
$str .= sprintf ("<OPTION VALUE=\"New\">New\n", New_);
$str .= sprintf ("<OPTION VALUE=\"Unused With Warranty\">Unused With Warranty\n", Unused_With_Warranty);
$str .= sprintf ("<OPTION VALUE=\"Unused\">Unused\n", Unused);
$str .= sprintf ("<OPTION VALUE=\"Rebuilt With Warranty\">Rebuilt With Warranty\n", Rebuilt_With_Warranty);
$str .= sprintf ("<OPTION VALUE=\"Rebuilt\">Rebuilt\n", Rebuilt);
$str .= sprintf ("<OPTION VALUE=\"Used\">Used\n", Used);
$str .= sprintf ("<OPTION VALUE=\"Running When Removed\">Running When Removed\n", Running_When_Removed);
$str .= sprintf ("<OPTION VALUE=\"Scrap\">Scrap\n", Scrap);
$str .= sprintf ("<OPTION VALUE=\"Salvage\">Salvage\n", Salvage);

$str .= sprintf ("<OPTION VALUE=\"%s\"></SELECT>\n", $value);

}
else  # display as read-only text
$str = $value;
printf ("<TD>%s</TD>\n", $str);
print ("</TR>\n");
}


###########################################################################
#                       END POP UP MENU SUBROUTINES
###########################################################################



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-02 00:33 UTC] zak@php.net
New (in any combination of case - i.e. new, NEW, NeW, ...) 
is a reserved word. Its presence indicates that you wish 
to instantiate a new object from an existing class.

i.e. 
class vegetable {
	var $name;

	function vegetable ($name) {
		$this->name = $name;
	}
}

$tomato = new vegetable ('tomato');

So this behavior is not out of line. However, define 
should probably throw an error when attempting to create a 
constant based on an reserved word.

I will work up a patch shortly.


 [2001-10-02 03:27 UTC] zak@php.net
Patch that checks for function/class name and reserved 
word conflicts sent to php-dev list.

 [2001-10-02 06:44 UTC] zak@php.net
The performance loss of adding reserved word checking to 
define() was deemed greater than the benefit. It looks 
like the behavior of define() will stay just the way it 
is. 

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC