Reputation: 7435
The error I'm getting here is:
Parse error: syntax error, unexpected 'CASE' (T_CASE), expecting identifier (T_STRING) in [filename] on line 4
<?php
class PartCategories {
const CASE = 1;
const PROCESSOR = 2;
const HARD_DRIVE = 3;
const MEMORY = 4;
}
Can't say I've tried anything but for the life of me can't see what's wrong here.
Why is this a syntax error?
Upvotes: 0
Views: 2538
Reputation: 1596
First of all you should know that PHP is not case sensitive. So "case", "Case", "caSE", "CAsE" and like are same thing.
And you already know that case is a php reserved keyword it can't be use for variable name.
You can initialize your class like
$obj = new PartCategories();
or paRTCATEgories();
or PARTCATEGORIES();
mEANS tO sAY THAt PHp iS CaSE INSEnsitive.
Upvotes: 0
Reputation: 9121
case
or CASE
is already reserved by PHP for the switch
statement. You can't redefine this as a constant, just as you cant define a const FUNCTION
or something similar.
You're going to have to change the name of the constant.
Upvotes: 3