Php 分析错误:语法错误,意外'';错误

Php 分析错误:语法错误,意外'';错误,php,Php,我有以下代码: <?php if(isset($_GET["update"])){ $id = $_GET["id"] ?? null; $where = array("id"=>$id); $row = $obj->select_record("medicines",$where); ?> 我明白了: 分析错误:语法错误,在第42行的C:\wamp\www\New folder\index.php

我有以下代码:

<?php if(isset($_GET["update"])){
        $id = $_GET["id"] ?? null;

        $where = array("id"=>$id);
        $row = $obj->select_record("medicines",$where);

        ?>

我明白了:

分析错误:语法错误,在第42行的C:\wamp\www\New folder\index.php中出现意外的“?”

除了上述代码,还有其他选择吗?

您应该使用:

 $id = $_GET['id']?$_GET['id']:null;

您使用的PHP版本是什么?我猜<7,看起来您已经编写了一些PHP7代码,但没有使用PHP7。。