【问题标题】:CakePHP Error: syntax error, unexpected T_STRING, expecting ',' or ';'CakePHP 错误:语法错误,意外的 T_STRING,期待 ',' 或 ';'
【发布时间】:2013-11-26 11:58:31
【问题描述】:

我收到语法错误注释代码。 有人可以知道为什么会出现这个错误

错误:语法错误,意外的 T_STRING,需要 ',' 或 ';' redmine/app/View/Welcome/index.ctp Line: 4

<h2><?php $this->Candy->html_title(__('Home'))  ?></h2>

<div class="splitcontentleft">
<!-- <%= textilizable Setting.welcome_text %> -->
<?php echo $this->Candy->textilizable($Settings->welcome_text) ?>
<?php if (!empty($news)): ?>
<div class="box">
<h3><?php echo __('Latest news')?></h3>
    <?php echo $this->element('news',array('news' => $news)) ?>
    <?php echo $this->Html->link(__('View all news'), array('controller' =>    
'news')) ?>
</div>
<?php endif; ?>
</div>

在 localhost 也可以正常工作,看来这是 .htaccess 文件的问题?

提前谢谢...!!!

【问题讨论】:

    标签: .htaccess cakephp cakephp-2.0 cakephp-2.3 cakephp-model


    【解决方案1】:

    我相信您的标题中缺少回声。像这样使用它:

    <h2><?php echo $this->Candy->html_title(__('Home')); ?></h2>
    

    【讨论】:

    • 好的,你可以备份这个文件并暂时删除该行及以上&lt;h2&gt;行吗?
    • @NarendraSinghRajpoot HTML 注释中的代码不是有效的 PHP 代码。
    • 对不起,如果这段代码无效,我是 cakePHP 的新成员,那么它在 localhost 中是如何工作的?
    • 正如我之前建议的那样,您可以备份这个文件并暂时删除&lt;h2&gt; 行以上的注释行吗?
    【解决方案2】:

    您在php.ini 中有asp_tags,这就是您收到此错误的原因。

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' 
    

    你可以在你的.htaccess 中禁用asp_tags 喜欢

    php_flag asp_tags off
    

    如果您只想为单个文件禁用它,您可以使用它

    <files file-with-asp-syntax.php>php_flag asp_tags off</files>
    

    你也可以用这个ini_set('asp_tags', 0)

    【讨论】:

      【解决方案3】:

      如果您启用了 asp_tags,则无论在 html 中注释的事实如何,都会处理 php 脚本。只需将其剥离 就可以了。

      如果这样的脚本会回显任何内容,它将被 html 注释但仍由 PHP 处理。

      【讨论】:

        猜你喜欢
        • 2019-05-26
        • 1970-01-01
        • 1970-01-01
        • 2013-07-15
        • 2017-06-20
        • 1970-01-01
        • 2013-04-12
        • 2010-11-20
        • 1970-01-01
        相关资源
        最近更新 更多