There is nothing weird here. It is a common pitfall that is even explained in the documentation.
The line:
$firstname = Case;
creates the PHP variable $firstname
and tries to assign to it the value of the Case
constant.
If the Case
constant has already been created (by a call to define()
or by a const
statement) then the above code copies its value into the $firstname
variable and that's all.
But if a Case
constant has not already been declared then the code above triggers a notice (E_NOTICE
) that you probably don't see because, by default, the PHP is configured to ignore the notices.
The PHP interpreter is tolerant and assumes you actually wanted to write 'Case'
and forgot the quotes. It then initializes the variable $firstname
with the string 'Case'
and this can help you identify the source of your error (the Case
constant has not been defined) even if you ignore the notices.
Assuming you want to initialize the variables with strings then the correct syntax for your code is:
$firstname = 'Case';
$lastname = 'Interstellar';
Read more about PHP strings.