I don't consider myself as PHP expert but I've designed several pages now containing a couple of thousand lines of code each. For my current project which is for a game site I drew back on an existing function which contains the line
$M–;
Now my basic understanding of PHP tells me this doesn't work since it should be -- for short -1. But it's not a dash, the script runs without error (error_reporting (E_ALL)
) but echoing $M
before and after gives me the same value.
So what does it do and why don't I get an error?
That's an en dash, which to PHP is just a random byte without specific meaning. $M–
, or in UTF-8 encoding 4DE28093
, is a valid variable name. Just like $漢字
.
A single variable by itself just initializes that variable to the line doesn't do anything null
if it doesn't already exist,else.
That code of your will result in a notice. First because that isn't a minus sign –
vs -
<- different (unless you have a variable name defined M–
).
Notice: Undefined variable: M– in
Second even if it was a minus sign it would spit out a notice.
Parse error: syntax error, unexpected ';' in
If anything it only shows you haven't properly enabled full error reporting or that you are using unicode characters in variable names just to screw with other people reading your code (including yourself). ;)
UPDATE
I misread your code a bit. What happens is that you have are initializing the variable M–
when doing that line so M–
will be null
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With