douzou7012 2013-06-26 17:52
浏览 76
已采纳

Netbeans php - 预期eof但发现}

I am using netbeans php 7.3 and cant seem to solve this warning " Expected EOF but found } "

The code is below. Its in a php file.

<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 throws up a red circle /exclamation mark on the second last line });

The php file is 600+ lines and so to make matters simple i pasted the code section into a new file and netbeans still threw an error at the same place });

  • 写回答

1条回答 默认 最新

  • douyou2732 2013-06-26 18:06
    关注

    I edited the code, try this now:

    <?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>
    

    About closing and opening php this is what I mean:

    This works but is not the bestway:

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

    This works but is much better:

    <?php
    endif;
    global $tag; ?>  
    

    Also if posible don't use global see more info about that see this url: https://stackoverflow.com/a/12446305/1788516

    Edit

    The problem is because there is javascript and php in the same file. for more information see this http://netbeans.org/bugzilla/show_bug.cgi?id=166694 for the bug.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里