Yesterday I took a part in interview for PHP developer postion. My job was to solve 15 questions in quite simple test. One of the questions was to mark all places, in given example PHP code, where execution would be stopped with fatal error. Among others, I marked as wrong something like that:
$this->someFunction(#);
The other person on interview told me, that I was wrong, because this is not a fatal error.
Can someone enlight me, why and how do we use hashes (#) in PHP function calls? I have never seen a construction like that and Google told me less than nothing on this (or maybe I did incorrect search).
The #
character is used for single-line comments.
It would be a syntax error on its own because there would be no )
$this->someFunction(#);
This is read as:
$this->someFunction(
But, if there are lines after this, then it's ok. Example:
$this->someFunction(#);
'a', 'b', 'c'
);
The #);
is a comment, and not parsed, so PHP sees
$this->someFunction(
'a', 'b', 'c'
);
Which is valid.
This will cause a 'parse error', not fatal. just simply check it yourself.
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