PHP-如果语句未评估为true,尽管被比较的值在逻辑上被验证为真

The value of valid is coming from another page after redirection.In the address bar the value of valid=%273%27. The value is echoing as '3', but still the if statement is evaluating to false.In the database table i have declared the type for variable valid as INT. I have tried changing the type for variable valid into TINYINT and ENUM and VARCHAR also,but to no use.

<?php
     $output="";
     if($_GET['valid']==3)
     {
                $output.="<br/><br/><br/>
                <h2>You are just one step behind completing your Profile.Please Upload Your Photo Here:</h2>
                <br/><br/><br/>";
               $output.="<form action=\"loadStudent.php\" method=\"post\" enctype=\"multipart/form-data\">";
                $output.="<table>";
                $output.="<tr>";
        $output.="<td align=\"right\"><font size=\"2\" face=\"Arial\"><strong>Picture</strong></font></td>";
         $output.="<td align=\"center\">:</td>";
         $output.="<td>";
         $output.="<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"10485760\">";
         $output.="<input type=\"file\" name=\"image\"  id=\"file\" size=\"255\"> <font size=\"5\" face=\"Arial\"> Maxsize 1MB</font>";
         $output.="</td>";
       $output.="</tr>";
      $output.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</td></tr>
                    <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</td><td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Submit\"></td>";
                    $output.=" </tr>";
                     $output.="</table>";
                 $output.="</form>";
                 echo $userId;
    echo $output;   

    }//if($valid==3)
    echo $_GET['valid'];
    ?>

if you see valid=%273%27 , it means that you are sending '3' with the single quote.

You could check for the value "'3'"

if($_GET['valid']=="'3'")

or remove it from the input

$valid = intval(str_replace("'",'',$_GET['valid']));
if ($valid == 3)

If you expect to receive a number/integer then typecast your $_GET variable to be an integer value to make sure what you get.

$number = (int)$_GET['valid'];
if($valid == 3) { ...

You will then notice that your variable is actually not the number 3 but it is a string, '3'.

You can also try dumping your variable to see what it really is with:

echo var_dump($_GET['valid']);

Otherwise as @progysm suggests you can compare on a string level:

if($_GET['valid'] == "'3'") { ...

try $_GET['valid']=="'3'" in your if statement.