The use of define and defined in php

autoload
Release: 2023-03-09 12:26:01
Original
2122 people have browsed it

The use of define and defined in php

For some fixed quantities in php, we often use constants to store them, so how to define constants? How to judge after defining it? This article will take you to take a look.

1. Use define to define a constant

<?php

 define ("PATH","/zend/php/define.php");
 echo PATH;
?>
Copy after login

2. Use defined to determine whether the constant exists

<?php
 define ("PATH","/zend/php/define.php");
 echo PATH."<br>";

 if(defined(&#39;PATH&#39;)){
    echo &#39;PATH&#39;."存在";
 }
?>
Copy after login
输出:/zend/php/define.php
      PATH存在
Copy after login

Recommended: 2021 PHP interview questions summary (collection)》《php video tutorial

The above is the detailed content of The use of define and defined in php. For more information, please follow other related articles on the PHP Chinese website!

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