Home  >  Article  >  Backend Development  >  The use of define and defined in php

The use of define and defined in php

autoload
autoloadOriginal
2021-04-28 10:42:192060browse

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;
?>

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;."存在";
 }
?>
输出:/zend/php/define.php
      PATH存在

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!

Statement:
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