|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74842 The use of "is set" in the definition of isset is vague.
Submitted: 2017-07-02 06:00 UTC Modified: 2017-07-02 17:13 UTC
From: dominic dot mayers at meditationstudies dot org Assigned:
Status: Open Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-07-02 06:00 UTC] dominic dot mayers at meditationstudies dot org
From manual page:
The definition should not be using "is set". Personally, I say that a variable cannot be set to NULL. For me, saying otherwise would be a contradiction, because we assign NULL to a variable to unset it. Others feel it makes sense to say that we set a variable to NULL, why not, it's a value. The point here is that "is set" is not very helpful in a definition. The extra "... and is not Null" helps, but it's hard to think because we still have these two cases. 

I am aware that another 8 years old bug mentions that the current definition seems a contradiction because we add "... and is not NULL". However, it is not a contradiction. It's either a useful addition, if we can set a variable to NULL, or redundant otherwise, but never a contradiction. The issue is more with "is set", because having two possible cases brings confusion.  

My native language is not English, but I would think something like "to determine if a variable has been assigned a non NULL value" would be more informative. The page could further recall that a way to unset a variable is to assign NULL to it. I would also recall that is_null is the opposite of isset.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-02 16:46 UTC] dominic dot mayers at meditationstudies dot org
The fact that is_null throws an exception when we use it with a variable that has never been assigned a value, but not when we have assigned NULL to it, suggests that we should have a different function, say isset_strict, to determine if a variable has been assigned a NULL or non NULL value to it. In fact, a few have proposed such a function in the comments. I am not suggesting it should be a built in function. I am just pointing out that an alternative view on "is set" is in the air. 

However, I feel it is important to bring out clearly, that the current definitions of isset, is_null and NULL are very harmonious and logical. In particular isset is the opposite of is_null, we unset a variable if we assign NULL to it, we set a variable if we assign a non NULL value to it and the purpose of isset is to determine if a variable is set. It's clean and simple. 

Note that we did not need the extra "... and is not NULL", which refers to a different view.  However, it is perhaps better not to use "is set", because it might conflict with the way some people use it.
 [2017-07-02 17:13 UTC] dominic dot mayers at meditationstudies dot org
The fact that unset($v) undo the effect of $v = NULL, also reinforces this other view where $v is set after $v = NULL. Again, just pointing out that this other view is in the air, It almost feels as if phpers have adopted the concept that isset does not determine if a variable is set.
 [2017-08-22 12:19 UTC] trainingsurat007 at gmail dot com
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Jul 23 01:01:25 2018 UTC