dtwzwmv87399 2012-09-26 13:06
浏览 22
已采纳

PHP在包含文件中打开大括号,但未关闭

Is it possible to separate try/catch block between separate files? For example, I have a page_start.php which opens the try:

<?php

    try {

and then this file is included at the start of various other files. The page_end.php is included at the bottom to close the try:

<?php
    } catch(Exception $e) {
        // Do something here
    }

When I try this I get:

Parse error: syntax error, unexpected $end in page_start.php on line X

Can this be done? Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dse3168 2012-09-26 13:11
    关注

    Check the manual out: http://php.net/manual/en/function.include.php

    It says this:

    The include statement includes and evaluates the specified file.

    The file is evaluated, so therefore it should contain valid PHP, and not end with an open 'stache. So the answer is no, it cannot be done.

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

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)