is it possible that a variable is referenced without using the $?
For example:
if ($a != 0 && a == true) {
...
}
I don’t think so, but the code (not written by me) doesn’t show an error and I think it’s weird. I’ve overlooked the code and a is not a constant either.
In PHP, a constant can be defined, which would then not have a
$, but a variable must have one. However, this is NOT a variable, and is not a substitute for a variable. Constants are intended to be defined exactly once and not changed throughout the lifetime of the script.Additionally, you cannot interpolate the value of a constant inside a double-quoted or HEREDOC string:
Finally, PHP may issue a notice for an
Use of undefined constant a - assumed 'a'and interpret it as a mistakenly unquoted string"a". Look in your error log to see if that is happening. In that case,"a" == TRUEis valid, since the string"a"is non-empty and it is compared loosely to the boolean TRUE.