Expecting statement after if
It is my code:
<?php
   if (empty($_COOKIE["count"]) && empty($_COOKIE["date"])) {
      setcookie("count",1);
      setcookie("date",date("d.m.y H:i"));
   } else {
      var $c=$_COOKIE["count"];
   }
?>
And I get error: expecting statement before var $c. How can I solve my problem?
 The var keyword is deprecated and was for use in classes, which this code snippet is not.  
Note: The PHP 4 method of declaring a variable with the var keyword is still supported for compatibility reasons (as a synonym for the public keyword). In PHP 5 before 5.1.3, its usage would generate an E_STRICT warning.
Just assign the variable normally:
$c = $_COOKIE['count'];
Otherwise, it is expecting to be inside of a class.
你需要在if语句之前声明变量$ c。
   <?php
       $c = 0;
       if (empty($_COOKIE["count"]) && empty($_COOKIE["date"])) {
          setcookie("count",1);
          setcookie("date",date("d.m.y H:i"));
       } else {
          $c=$_COOKIE["count"];
       }
    ?>
上一篇: 这个PHP行有什么问题?
下一篇: 在if之后期望陈述
