1

I'm using CakePHP and when baking a table "cases", I get syntax error, unexpected T_CASE, expecting T_STRING from the model

<?php
App::uses('AppModel', 'Model');
/**
 * Case Model
 *
 */
class Case extends AppModel {

I'm guessing the error is because the class name is "Case", based off the db table. Is this correct? Are we not able to use "Case" as a class name?

8
  • 3
    Yep, 'case' is a reserved word. Commented Jan 9, 2014 at 22:57
  • indeed Commented Jan 9, 2014 at 22:58
  • @jameslafferty - thanks, will defining a namespace make a difference? Commented Jan 9, 2014 at 22:58
  • 1
    @dcd018: Probably not. You can't name it Case is the issue. You need to use another name. Commented Jan 9, 2014 at 22:58
  • 1
    @samira Your edit was wrong and I'm going to roll it back. Code spans and code blocks are commonly used for error messages and other output, in fact that's considered the preferred way to mark output. More generally...there seems to be an exceptionally easy panel of reviewers this evening who are rubber-stamping every suggested edit within seconds, but most of the edits you've been submitting are really not constructive. Please find things that actually need to be fixed and are significant enough to be worth editing rather than using suggested edits as a way to score rep with minimal effort. Commented Jan 9, 2014 at 23:17

1 Answer 1

1

Case / case is a reserved word by PHP. You can try to use a prefix or just another name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.