This repository was archived by the owner on Jan 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample.php
96 lines (69 loc) · 2.27 KB
/
example.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
// Make sure to include the class file.
require_once 'ParseUrl.php';
// The URL we're using.
$example = 'http://www.cryode.com';
// Instantiate the URL. The construct function will do all the work.
$url = new ParseUrl($example);
/**
* Here's an example of a URL with no "http[s]://".
* You can set a boolean property in the class that defines
* whether or not to auto-fill it in when missing.
*
* This is an example of the results if that setting is OFF.
*/
$badExample = 'my-website.co.uk';
$badUrl = new ParseUrl($badExample);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>ParseUrl Examples</title>
<style>
body {
background-color: #D4D0DA;
color: #333;
font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;
padding: 0 30px 30px;
}
h3 {
border-bottom: 1px solid #BAB5C2;
color: #44286F;
font-size: 26px;
font-weight: normal;
padding-bottom: 5px;
}
code {
background-color: #FFF4F2;
-webkit-box-shadow: 1px 1px 1px #BAB5C2;
-moz-box-shadow: 1px 1px 1px #BAB5C2;
-o-box-shadow: 1px 1px 1px #BAB5C2;
box-shadow: 1px 1px 1px #BAB5C2;
color: #276D56;
display: inline-block;
font-family: 'Menlo Regular', 'Monaco', 'Courier New', monospace;
font-size: 13px;
padding: 0 3px;
}
</style>
</head>
<body>
<h3>Example URL: <?php echo $example; ?></h3>
<p>isValid() Result: <code><?php var_dump($url->isValid()); ?></code></p>
<p>hasDomain() Result: <code><?php var_dump($url->hasDomain()); ?></code></p>
<p>getDomain() Result: <code><?php var_dump($url->getDomain()); ?></code></p>
<p>getTld() Result: <code><?php var_dump($url->getTld()); ?></code></p>
<p>hasQuery() Result: <code><?php var_dump($url->hasQuery()); ?></code></p>
<p>Try running <code>getNothing()</code>. It'll throw an Exception.</p>
<h3>Bad Example URL: <?php echo $badExample; ?></h3>
<p>isValid() Result: <code><?php var_dump($badUrl->isValid()); ?></code></p>
<p>getError() Result: <code><?php var_dump($badUrl->getError()); ?></code></p>
<p>
Note that if the class runs into an error, it stops processing at that point.<br>
So some or all properties and/or magic methods will not return values.
</p>
</body>
</html>