自由屋推书网—热门的小说推荐平台!

你的位置: 首页 > php

PHP函数file_exists()判断文件是否存在并执行逻辑运

2022-05-16 10:31:08

以下代码用于判断目录下的 footer.php 是否存在,如果是则 include 该文件,如果否则 include 后续文件 default_footer.php

<?php file_exists('footer.php') ? include('footer.php') : include('default_footer.php'); ?>

其中 file_exists('footer.php') ? include('footer.php') 中的 footer.php 前后者的名称可以不是相同名称,其中逻辑前者判断该文件是存在,可以用于或不用于 include ,后者只用于 include 。

php

编辑推荐

热门小说