Programme 1#
<?php
function has_space($string){
if (preg_match('/ /', $string)){
return true;
}else{
return false;
}
}
$string='This doesnt have a space';
if (has_space($string)){
echo 'has at least one space';
}else{
echo 'has no space.';
}
?>
Programme 2#
<?php
if(isset($_GET['user_name'])&&!empty($_GET['user_name'])){
$user_name=$_GET['user_name'];
$user_name_lc=strtolower($user_name);
if($user_name_lc=='alex'){
echo 'You are the best';
}else{
echo 'You are not alex';
}
}
?>
<form action="index.php" method="GET">
Name:<input type="text" name="user_name"><br><br>
<input type="submit" value="Submit">
</form>
No comments:
Post a Comment