If echo
can work withouth the parentheses why exit
can't?
They're both language constructs (T_ECHO and T_EXIT), but different kinds. You can use exit without parentheses, but not if you're passing a value. Another quirk is that echo requires you not to use parentheses if you pass more than one value:
php > echo 'foo', 'bar';
foobar
php > echo ('foo', 'bar');
PHP Parse error: syntax error, unexpected ',' in php shell code on line 1
If you're now thinking, "But that doesn't really explain why the design is inconsistent", welcome to PHP.
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