duanjian7617 2012-03-30 09:53
浏览 29
已采纳

PHP解析错误:语法错误,如果{}中带有$ _GET []的意外'}'

I have the following php-code that I don't seem to be able to get working:

<?php
    if($_GET['sizex'] == null) { 
        $sizex = 200; 
    } else { 
        $sizex = $_GET['sizex']; // This is the problematic line
    }
?>

When I try to run it, I get the following error:

PHP Parse error:  syntax error, unexpected '}' in test.php on line 6

I have found out that the $_GET[] causes this, because if I replace it with anything else like $sizex = 1, it works fine. Is there some typo which I cant see, or is there something special about $_GET that I don't know?

var_dump($_GET):

array(1) {
  ["sizex"]=>
  string(1) "1"
}
  • 写回答

2条回答 默认 最新

  • dovgqc2648 2012-03-30 09:59
    关注

    This code works fine. There is no syntax error there. Probably you have some weird invisible characters. Try to clear all newlines and then insert them back.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误