php - Can't declare class constant nor property variable

650
class Model {

  public $DATABASE_NAME = 'dealer-kunde-skuska';

       // OR

  const DATABASE_NAME = 'dealer-kunde-skuska';

}

None of above declarations works. It returns error:

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in ... on line 5

What could be wrong?

209

Answer

Solution:

public andconst are only available as of PHP 5.var is used in PHP 4.

Support for PHP 4 has been discontinued since 2007-12-31. Please consider upgrading to PHP 5.

Upgrade maybe? PHP 5 has been around for 11 years and PHP 4 discontinued for 7.

People are also looking for solutions to the problem: php - Adding vertical text into existing pdf

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.