当使用非!defined值时,PHP未定义的常量错误,任何其他选择。
我的守则:-
<a href="http://'.<?php !defined(DOMAIN) ? print('localhost') : print(MY_DOMAIN); ?>.'" target='_blank'>My Website</a>但这给了我错误:
<a href="http://<br />
<b>Notice</b>: Use of undefined constant DOMAIN - assumed 'DOMAIN' in <b>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\url.php</b> on line <b>3</b><br />localhost" target='_blank'>My Website</a>如果我不使用,它不应该只打印本地主机:-
define('DOMAIN', 'example.com');还有其他方法可以指定!定义值吗?
发布于 2013-07-03 17:46:44
你必须用引号括住常量的名称。
<a href="http://'.<?php !defined("DOMAIN") ? print('localhost') : print(DOMAIN); ?>.'" target='_blank'>My Website</a>否则,它将像这样工作:(因为您将传递const的值)
define("DOMAIN", 'example.com');defined(DOMAIN)将等于defined('example.com')
https://stackoverflow.com/questions/17454839
复制相似问题