Netbeans php - 预期eof但发现}

时间:2013-06-26 17:52:29

标签: php netbeans eof

我正在使用netbeans php 7.3并且似乎无法解决此警告 “预期的EOF但发现了}”

代码如下。它在一个php文件中。

<script type="text/javascript">
function downloadStats($filename,$album,$type){                        
$('#downloaddiv').html('<img src="images/ajax-loader.gif" />');
    $.ajax({
        type: 'POST',
        url: 'download.php',

<?php
    if($_GET['urltype']=='basketball'){
?>
        data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&area=source&uploadyear=<?php echo $uploadyear;?>",
<?php
    } else {
?>
        data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&uploadyear=<?php echo $uploadyear;?>",
<?php
    }
?>
<?php global $tag; ?> 
        success: function(msg) {
            $('#downloaddiv').html('<b title="Stat available for download. Click HERE to download."  ><?php echo $tag['view_013'];?> <?php echo $tag['view_014'];?> <a href="'+msg+'"><?php echo $tag['view_015'];?></a> <?php echo $tag['view_016'];?></b>');
        }

    });   <===  red circle/exclamation mark here
}
</script>

Netbeans在倒数第二行抛出一个红色圆圈/感叹号});

php文件是600多行,所以为了简单起见我将代码段粘贴到一个新文件中,netbeans仍然在同一个地方抛出错误});

1 个答案:

答案 0 :(得分:1)

我编辑了代码,现在试试这个:

<?php
function downloadStats($filename,$album,$type){
?>                     
$('#downloaddiv').html('<img src="images/ajax-loader.gif" />');
$.ajax({
    type: 'POST',
    url: 'download.php',

<?php
if($_GET['urltype']=='basketball') :
?>
    data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&area=source&uploadyear=<?php echo $uploadyear;?>",
<?php
else :
?>
    data: "filename=" + $filename + "&album=" + $album + "&type=" + $type + "&uploadyear=<?php echo $uploadyear;?>",
<?php
endif;
global $tag; ?> 
    success: function(msg) {
        $('#downloaddiv').html('<b title="Stat available for download. Click HERE to download."  ><?php echo $tag['view_013'];?> <?php echo $tag['view_014'];?> <a href="'+msg+'"><?php echo $tag['view_015'];?></a> <?php echo $tag['view_016'];?></b>');
    }

});
<?php
}
?>


<script type="text/javascript">
<?php echo downloadStats($filename,$album,$type); ?>
</script>

关于关闭和打开php这就是我的意思:

这可行,但不是最好的方式:

<?php
endif;
?>
<?php
global $tag; ?> 

这样可行但更好:

<?php
endif;
global $tag; ?>  

如果posible不使用global,请查看有关该信息的更多信息,请参阅此网址:https://stackoverflow.com/a/12446305/1788516

修改

问题是因为在同一个文件中有javascript和php。有关更多信息,请参阅此http://netbeans.org/bugzilla/show_bug.cgi?id=166694以获取错误。