Home > Backend Development > PHP Tutorial > How does php determine whether a constant is defined?

How does php determine whether a constant is defined?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:00:20
Original
2052 people have browsed it

Use the defined function

defined(String constants_name)

If the constant exists, return bool(true)

If it does not exist, return bool(false)

<?php 
define("name",unique);
$p = "name";
$is1 = defined($p);
$is2 = defined("p2");

var_dump($is1);
var_dump($is2);
?>
Copy after login

The above introduces how PHP determines whether a constant is defined? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

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