PHP中的这两行有什么区别.它们都是变量吗?


Whats the difference between these two lines in PHP....Are they both variables?

有:

$myvar="somthing";

和:

define('myvar', 'something');

我知道第一个正在定义一个变量,我认为第二个也是,直到有人告诉我它不是......

两者之间有什么区别?他们都做同样的事情,对吗?

第二个创建一个常量。 从语法上讲,它很像一个变量,只是它不能变化。

请参阅 http://php.net/manual/en/function.define.php,或更一般地 http://www.php.net/manual/en/language.constants.php。