简体   繁体   中英

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

I have an old osCommerce site that was PHP4, now running on PHP5. Named constants defined with define() are being evaluated incorrectly:

$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 .

Something needs to be changed in php.ini ?

No, AFAIK constants behavior hasn't changed.

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.

Most probably, that define isn't being define() 'd correctly. The default behaviour (with error reporting relaxed) is to show the constant like that when it isn't found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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