PHP String Programs with Examples

Program 1

<html>
    <head><title>String in PHP Application</title>
    <body>
  
  <pre>
    <center>
<?php
                $email="[email protected]";
                $m=substr_count($email,"@");
                $f=0;
                if($m==1)
                {
                     for($i=0;$i<strlen($email);$i++)
                     {
                           if($email[$i]=='@')
                           {
                                 $f=$i;
                                 break;           
                           }
                     }
                     $n=substr_count($email,".",$f+1);
                    if($n==1) 
                    echo "<font color=green size=5>Valid email id</font>";
                   else
                   echo "<font color=red size=5>Invalid email id</font>";
                }
                else
                echo "<font color=red size=5>Invalid email id</font>";
                //echo $m;
?>
    </center>

 

courses

Leave a Reply

Your email address will not be published. Required fields are marked *