使用常量出错

2022-01-23 00:00:00 constants php

我有很多页面,所有页面都需要文件characters.php.该文件包含在我的网站中定义许多内容的常量.它们是这样定义的,例如:

I have a lot of pages, all of which require the file characters.php. This file contains constants which define many things in my website. They are defined like this, for example:

const $humanHEALTH = 1.1;

使用 WAMP 在我的本地主机中运行它一切正常,但是当我将它上传到在线主机时,我收到此错误:

Everything works properly running it in my localhost using WAMP, but when I upload it to an online host I get this error:

解析错误:语法错误,意外的 T_CONST

Parse error: syntax error, unexpected T_CONST

我在其中一个页面上使用了 phpinfo(),PHP 版本是 5.2.17.

I used phpinfo() on one of the pages and the PHP version is 5.2.17.

任何帮助将不胜感激.

推荐答案

在 PHP 5.2 中是 define('constant_name', 'value');

In PHP 5.2 it's define('constant_name', 'value');

相关文章