|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60305 myClass::unset() keyword conflict
Submitted: 2011-11-15 02:19 UTC Modified: 2012-04-03 01:43 UTC
Avg. Score:3.9 ± 1.6
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:4 (57.1%)
From: matty023 at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4.0RC1 OS:
Private report: No CVE-ID: None
 [2011-11-15 02:19 UTC] matty023 at gmail dot com
While "keywords" and "language constructs" cannot be used as function names, I find myself with the need to have a function in my class named "unset", I also see that list is a very common and useful term.

After the introduction of classes and namespaces it's time to look at enabling usage of these common terms in classes and namespaces.

Test script:
namespace whatever;
class unsetTest{
	function unset($whatever){

Expected result:

Actual result:
//Parse error: syntax error, unexpected 'unset' (T_UNSET), expecting identifier (T_STRING) in E:\_www\x.php on line #


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-15 19:32 UTC] francois dot dambrine at isen-lille dot fr
This bug also happen in php 5.3.6 (ubuntu 11.10 default version).
 [2011-11-21 03:50 UTC] anon at anon dot anon
@francois: It's not a bug. It's a feature.

It's kind of accepted that all programming languages have some keywords you can't use as identifier names. The general solution is to just choose a synonym. Possible alternative verbs for "unset" include:
- clear
- remove
- delete
- dispose
- drop
- erase

Unusually, the language limitation is actually fixable for "unset" because of its obvious function-like syntax. It's probably not a priority though. Also, at best, it would break the history of PHP syntax-coloring editors turning "unset" keyword color.
 [2012-04-03 01:43 UTC]
-Status: Open +Status: Not a bug
 [2012-04-03 01:43 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

unset is keyword, so you cannot use it as previous comment describes.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun May 26 03:01:26 2019 UTC