代码

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

说明

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

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


何星星原创文章仅用于个人学习,当前页面暂不支持复制操作,了解详情或文章转载请 点此 继续!

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注