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

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.

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

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥50 成都蓉城足球俱乐部小程序抢票