dtvnbe1428 2012-10-22 07:27
浏览 73
已采纳

排除if语句?

Is it somehow possible to exclude an if statement to two different files? When I write something like the following code, it gives a parse error: syntax error, unexpected end of file. Apparently, i always have to close an if statement in the same included file. Is there a way to accomplish what i want?

index.php:

<?php
require "top.inc.php"; // opening the if statement
  some code to execute if statement in top.inc.php is true
require "bottom.inc.php"; // closing the if statement
?>

top.inc.php:

<?php if (1 == 1) { ?>

bottom.inc.php:

<?php } ?>
  • 写回答

4条回答 默认 最新

  • doupingmao1903 2012-10-22 07:32
    关注

    No, it is not possible. Each .php file needs to have complete, valid syntax. includeing files is not exactly the same as copy-and-pasting their content.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!