I'm getting an error when I try to define a constant named DEFAULT
. Why is this?
<?php
define('DEFAULT', true);
var_dump(DEFAULT);
// or
class Test {
const DEFAULT = true;
}
var_dump(Test::DEFAULT);
This results in the following error:
Parse error: syntax error, unexpected 'DEFAULT' (T_DEFAULT) in ... on line X
default
is a reserved language keyword in PHP. It is used for the default option in a switch
block.
So no, you can't use it in a define
statement.
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