PHP中define跟defined的区别

WBOY
Release: 2016-06-13 13:25:52
Original
928 people have browsed it

PHP中define和defined的区别

PHP中define和defined的区别

对于初学者会混淆这两个函数

?

1.define用来定义一个常量,常量也是全局范围的。不用管作用域就可以在脚本的任何地方访问 常量。一个常量一旦被定义,就不能再改变或者取消定义 如:define("website","www.phperz.com") www.phperz.com为常量website的值。

?

2.defined用来检测常量有没有被定义,若常量存在,则返回 true,否则返回 false如: if(defined("website")){ echo "true"; }else{ echo "false"; }

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template