-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreg_match.php
47 lines (43 loc) · 946 Bytes
/
preg_match.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
function has_space($string){
if(preg_match('/ /',$string)){
return true;
}else{
return false;
}
}
//
// if(isset($_POST['submit'])){
// if(has_space($_POST['input'])){
// echo "has at least one space"."<br>";
// }else{
// echo "has no space"."<br>";
// }
// }
function domainCheck(){
if (preg_match('@^(?:http://)?([^/]+)@i',$_POST['url'], $matches)) {
$host = $matches[1];
echo $host;
}
}
domainCheck();
//
// if (isset($_POST['submit'])) {
// if (domainCheck($_POST['url'])) {
// echo $_POST['url'];
// }
// }
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form class="" action="<?php PHP_SELF?>" method="post">
<input type="text" name="url" placeholder="Input">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>