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

报告相同问题?

悬赏问题

  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统