简体   繁体   English

PHP将常量prints / concats命名为变量名,而不是值

[英]PHP named constant prints/concats as the variable name, not value

I have an old osCommerce site that was PHP4, now running on PHP5. 我有一个旧的osCommerce网站,它是PHP4,现在在PHP5上运行。 Named constants defined with define() are being evaluated incorrectly: define()命名常量被错误地求值:

$string = '<a href="http://www.oscommerce.com" target="_blank">' . BOX_ENTRY_SUPPORT_SITE . '</a><br>';

will show as BOX_ENTRY_SUPPORT_SITE , not the value placed in BOX_ENTRY_SUPPORT_SITE . 将显示为BOX_ENTRY_SUPPORT_SITE ,不放在值BOX_ENTRY_SUPPORT_SITE

Something needs to be changed in php.ini ? 需要在php.ini进行某些更改吗?

No, AFAIK constants behavior hasn't changed. 不,AFAIK常数行为未更改。

Most likely the constant is not defined; 该常量很可能没有定义; try to find where it's being defined and see if the file is being loaded by your script (ie: by require or include) 尝试找到它的定义位置,然后查看脚本是否正在加载文件(即:按要求或包含)

I never ran into this problem when putting osCommerce sites on PHP5 from PHP4. 将osCommerce网站从PHP4放到PHP5时,我从未遇到过这个问题。

Most probably, that define isn't being define() 'd correctly. 最有可能的是,该定义未正确被define()正确。 The default behaviour (with error reporting relaxed) is to show the constant like that when it isn't found. 默认行为 (放宽了错误报告的状态)是在未找到常量时显示该常量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM