第25行的C:\ xampp \ htdocs \ assign \ xtra assign.php中意外的'if'(T_IF)[关闭]

 <html>
 <body>

 <form name="form1" method="post" action="xtra assign.php">

  <h1>Malaysia Identification Card(IC)</h1>

 Enter IC NO : <input type="text" name="IC" id="IC"><br>

 <input type="submit" name="submit" value="submit">
  <input type="reset" name="clear" value="clear">

 </form>
 </body>
 </html>

In this php , I need to add 3 functions: is_numeric,substr and strlen, but I get so many errors. Also i also i need to make difference if the end number is even or odd. if the end number is odd, it is gentlement, if the end number is even, it is a lady.

<?php

if(isset($_POST['submit']))
{
$IC=$_POST['IC'];
substr($IC,-1);
$IC=123456789012;

can i use this code?

if(is_numeric($IC) &&strlen($IC===12)) 
{
  echo"CARD HOLDER IS A GENTLEMAN";
} 

can i use this the same like if?

else (is_numeric($IC) &&strlen($IC===12) &&substr($IC,-1))
{
 echo "CARD HOLDER IS A LADY";
 }


else 
{
 echo "THE IC NUMBER IS INVALID";
}
}
 ?>

Usually this is the result of a missing semicolon. Make sure the statement prior to line 25 ends with ;.

No. You cannot have TWO else clauses. You can chain if/elseif/elseif/.... as deep as you want, but there can only be ONE else clause.

Plus, your substr($IC,-1) is an utterly pointless call. You'r not capturing the returned substring, so all it's doing is wasting some CPU cycles.

if (...) {
  ...
} else if (...) {
   ..
} else if (...) {
   .... lots more elseifs
} else {
   ... the only allowed ELSE clause 
}

Most likely what you want is somethin like this:

if (is_numeric($IC)) {
    if (strlen($IC) == 12) {
        if (...) {
             ... everything is a-ok
        } else {
           die('condition failed');
        }
    } else {
         die("wrong length");
    }
} else {
    die("not numeric");
}

However, be careful of nesting if() conditions too deeply. It quickly becomes unreadable and difficult to maintain.

There are several things wrong here.

strlen($IC=12) <-- this is an assignment statement, not a comparison.

else 
{
 echo "CARD HOLDER IS A LADY";
 }
else
{
 echo "THE IC NUMBER IS INVALID";
} <-- you cannot chain elses like this

You also have an unmatched bracket at the end of the elses.

$IC=123456789012 <-- needs a semi colon