Saturday, August 27, 2022

String Function PHP

LOGIN 

 <form action="login.php" method="get">  Enter the password:<input type="password" name="pass" ><input type="submit" name="submit" ></form>

<?php

if (isset($_GET['submit'])){
    $var =$_GET['pass'];}
if((strlen($var))<=7){
    echo "Password should be lenght";}
else{
    echo "login";}
?>

SEARCHING STRING
<form action="string.php" method="get">
    Enter name:<input type="text" name="name" >
<input type="submit" name="submit" >
</form>
<?php
if (isset($_GET['submit']))
{
if (strlen($_GET['name'])<=7) {
    echo "Must be use & lenght of string"; }
else{
    echo "complete";
}}
?>

<h1>WORD COUNT CONDITION STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click">
</form>
<?php
if (isset($_GET['click'])) {
$i=str_word_count($_GET['name']);
if ($i>1) {
 echo "you should be enter only single name";}
else 
{echo "complete";}}
?>

<h1>SPECIFIC WORD PRINT @ STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click" value="enter">
</form>
<?php
if (isset($_GET['click'])) {
    $i=str_word_count($_GET['name']);
    echo (strstr($_GET['name'],"@")?"yes":"No")."<br>";}
?>

<h1>WORD COUNT STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click">
</form>
<?php
if (isset($_GET['click'])) {
 echo "total number of words are here=".str_word_count($_GET['name']);}
?>

<h1>SPECIFIC WORD PRINT STRING</h1>
<form>
 enter name:-<input type="text" name="name">
 <input type="submit" name="click" value="enter">
</form>
<?php
if (isset($_GET['click'])) {
    $i=str_word_count($_GET['name']);
    echo strstr($_GET['name'],"kumar");}
?>

No comments:

Post a Comment