-2
class Case {
// class body
}

It's because the "Case" word is reserved by the switch statement? Workarounds? Ideas?

Lucas Freitas
  • 194
  • 12

3 Answers3

5

Because case is the reserved word.

Reserved words can not be used as constants, function names, class names and etc. Try to avoid that.

BlitZ
  • 12,038
  • 3
  • 49
  • 68
  • The reserved word is 'case' not 'Case', so I would expect the name 'Case' to be a valid class name. – Kwebble Apr 08 '16 at 15:26
  • @Kwebble Reserved words are case insensitive: http://stackoverflow.com/questions/20624257/are-php-keywords-case-sensitive – BlitZ Apr 08 '16 at 16:54
0

Yes. It is a reserved word. Just rename your class.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
0

PHP has a list of reserved words: http://www.php.net/manual/en/reserved.keywords.php

These can't be used in the way you're trying, ie as constants, class names, function or method names.

No way around it, and no real work arounds. Pear naming convention is OK though, Folder_Folder_Case wouldn't cause any problems.

Ricky S
  • 371
  • 1
  • 8