文件末尾出现意外的文件结束错误

时间:2012-12-17 22:45:16

标签: php

运行下面的示例代码时遇到问题。它说:代码末尾的“语法错误,文件意外结束”。有人能帮我吗? 我也不明白<? ?>是否与<?php ?>的工作方式相同。 感谢

    <?php 
    /**
     * @copyright Copyright (C) DocuSign, Inc.  All rights reserved.
     *
     * This source code is intended only as a supplement to DocuSign SDK
     * and/or on-line documentation.
     * This sample is designed to demonstrate DocuSign features and is not intended
     * for production use. Code and policy for a production application must be
     * developed to meet the specific data and security requirements of the
     * application.
     *
     * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
     * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
     * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
     * PARTICULAR PURPOSE.
     */

    /*
     * Lists status of all envelopes in an account
     */

    //========================================================================
    // Includes
    //========================================================================
    include_once 'include/session.php'; // initializes session and provides
    include_once 'api/APIService.php';
    include 'include/utils.php';

    //========================================================================
    // Functions
    //========================================================================
    function createStatusTable() {
        $count = count($_SESSION["EnvelopeID"]);
        if (isset($_SESSION["EnvelopeID"]) && count($_SESSION["EnvelopeID"]) > 0) {
            $api = getAPI();

            $filter = new EnvelopeStatusFilter();
            $filter->AccountId = $_SESSION["AccountID"];
            $filter->EnvelopeIds = $_SESSION["EnvelopeID"];
            try {
                $rsexParams = new RequestStatusesEx();
                $rsexParams->EnvelopeStatusFilter = $filter;
                $statuses = $api->RequestStatusesEx($rsexParams)->RequestStatusesExResult;
            } catch (SoapFault $e) {
                $_SESSION["errorMessage"] = $e;

                header("Location: error.php");
            }

            if (isset($statuses)) {
                pr($statuses);
                ?> <ul class=""> <?
                foreach ($statuses->EnvelopeStatuses->EnvelopeStatus as $status) {
                   ?>
                        <li>
                            <span><u><?= $status->Subject ?></u> 
                                [ <?= $status->Status ?> ] - 
                                <?= $status->EnvelopeID; ?> 
                                <a href="getstatusofenvelope.php?envelopeid=<?= $status->EnvelopeID; ?>" target="_blank" title="Click to see a RequestStatus SOAP return for this Envelope">View RequestStatus</a>
                                &nbsp;&nbsp;<a href="getpdf.php?envelopeid=<?= $status->EnvelopeID; ?>" target="_blank" title="Click to download PDF for this Envelope">Download PDF</a></span>
                            <ul>
                                <!-- Recipients -->
                                <li>
                                    <span>Recipients ( <?= count($status->RecipientStatuses->RecipientStatus); ?> )</span>
                                    <ul id="<?= $status->EnvelopeID; ?>">

                                        <? foreach($status->RecipientStatuses->RecipientStatus as $rcpStatus){ ?>
                                                    <li>
                                                        <!-- Recipient Name and Start Signing -->
                                                        <?
                                                            echo $rcpStatus->UserName;
                                                        ?> 
                                                        <a href="embeddocusign.php?from_gsad=1&envelopeID=<?= $status->EnvelopeID; ?>&clientID=<?= $rcpStatus->ClientUserId ?>">Start Signing</a>
                                                    </li>
                                        <? } ?>

                                    </ul>
                                </li>


                                <!-- Documents -->
                                <li>
                                    <span>Documents ( <?= count($status->DocumentStatuses->DocumentStatus); ?> )</span>
                                    <ul>
                                        <? foreach($status->DocumentStatuses->DocumentStatus as $docStatus){ ?>
                                                <li>
                                                    <?= $docStatus->Name; ?>
                                                </li>
                                        <? } ?>
                                    </ul>
                                </li>

                            </ul>
                        </li>
                   <?
                    };
                ?> </ul> <?
            }
        } else {
          // No Envelopes created yet
                echo '<tr><td><div class="sampleMessage">';
                echo '  No envelopes created, yet. Use the tabs to create an Envelope.';
                echo '</div></td></tr>';

        }
    }

    //========================================================================
    // Main
    //========================================================================
    loginCheck();

    if ($_SERVER["REQUEST_METHOD"] == "POST") {

    }
    else if ($_SERVER["REQUEST_METHOD"] == "GET") {

    }

    ?>

    <!DOCTYPE html">
    <html>
        <head>
            <link rel="stylesheet" href="css/default.css" />
            <link rel="stylesheet" type="text/css" href="css/GetStatusAndDocs.css" />
            <script type="text/javascript" src="js/Utils.js"></script>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>

            <script type="text/javascript">
                    // Invert rows when clicking (not implemented, simple enough to view without deep-clicking)
                    function invert(ident) {
                        var state = document.getElementById(ident).style.display;
                        if (state == 'block') {
                            document.getElementById(ident).style.display = 'none';
                        } else {
                            document.getElementById(ident).style.display = 'block';
                        }
                    }
                </script>

            <div class="container">
                <div class="authbox">
                    <span><?php echo $_SESSION["UserID"]; ?></span> 
                    (<a href="index.php?logout">logout</a>)
                </div>
                <table class="tabs" cellspacing="0" cellpadding="0">
                    <tr>
                    <td><a href="senddocument.php">Send Document</a></td>
                    <td><a href="sendatemplate.php">Send a Template</a></td>
                    <td><a href="embeddocusign.php">Embed Docusign</a></td>
                    <td class="current">Get Status and Docs</td>
                    </tr>
                </table>
                    <div id="statusDiv">
                    <?php createStatusTable(); ?>
                </div>
             <?php include 'include/footer.html'; ?>
            </div>
        </body>
    </html>

2 个答案:

答案 0 :(得分:0)

Ahhh!您必须在short_open_tag文件中打开php.ini,才能使速记<? ?>正常工作。

  

来自the documentation

     

short_open_tag boolean - 告诉PHP PHP的开放标记的缩写形式(<? ?>)是否应该是   允许。如果要将PHP与XML结合使用,则可以   禁用此选项以使用内联<?xml ?>。否则,你   可以用PHP打印,例如:
  <?php echo '<?xml> version="1.0"?>'; ?>

     

此外,如果禁用,则必须使用长格式的PHP开放代码(<?php ?>
  (重点和格式被更改)

答案 1 :(得分:0)

对于某些服务器,我有这个错误,因为我写了<?而不是<?php ...