Home > Article > Backend Development > 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('PATH')){ echo 'PATH'."存在"; } ?>
输出:/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!