douyi8732 2017-02-10 04:43
浏览 34
已采纳

PHP定义常量声明

I do not understand how this code work. displaying code below , in this code i defined a constant and the value is 10 but it display the output "constant is not defined".

why?

define('HELLO', 10);        
if(defined(HELLO))        
{        
    echo "Constant is defined";        
}        
else        
{        
    echo "Constant is not defined";        
}        

?>
  • 写回答

1条回答 默认 最新

  • dongtan5558 2017-02-10 04:47
    关注

    change:

    defined(HELLO)
    

    to:

    defined('HELLO')
    

    http://php.net/manual/en/function.defined.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?