English 中文(简体)
取决于php 剖析器, 我有一个语法错误
原标题:Depending on php parser I get a syntax error
  • 时间:2012-05-22 17:07:51
  •  标签:
  • php

我只是缩小了一个奇怪的错误, 在某些环境里发生了。

下面的代码可以放在我的 Linux php 5.3.6 默认安装上,放在窗口 php 5.4.3 默认安装上,但是在Windows php 5.3.6 的窗口机器上却失败了。

我们得到的信息是:

分析错误: 语法错误, C:\\ ogus.php 中未预料的 }

第7行是"}"。

我只能认为这个错误是由php.ini设置造成的。有人知道问题是什么吗?

<?php
if(!empty($data[ foo ])) {
    ?>
    <div>
        <?=$data[ bar ];if(!empty($data[ foo ])) {?> (Foo: <?=$data[ foo ];?>) <?php }?></div>
    <?php
}
?>      
最佳回答

这看起来很奇怪:

<?=$data[ bar ];if(!empty($data[ foo ])) {?>

您正在将

但不管怎么说,我认为这意味着窗口机器没有在php.ini 中启用 < code> short_ open_tags 。 启用它, 您的问题可能会消失 。

问题回答

我会改变所有那些

<?php if(!empty($data[ foo ])):?>
    <div>
        <?php echo $data[ bar ];
         if(!empty($data[ foo ])):?> 
              (Foo: <?php echo $data[ foo ]?>) 
        <?php endif?>
    </div>
<?php endif?>      
<?php
if(!empty($data[ foo ])) {
    echo  <div> .$data[ bar ];if(!empty($data[ foo ]))echo  Foo: .$data[ foo ]; 
echo  </div> ;
}
?>

使用回回回函数





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签