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条)

报告相同问题?

悬赏问题

  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别