-
Notifications
You must be signed in to change notification settings - Fork 0
/
8-randomly-useful-php-tricks-1acfd89a3fb4.html
220 lines (168 loc) · 7.06 KB
/
8-randomly-useful-php-tricks-1acfd89a3fb4.html
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="" />
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,700;1,400&family=Source+Sans+Pro:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./theme/stylesheet/style.min.css">
<link id="pygments-light-theme" rel="stylesheet" type="text/css"
href="./theme/pygments/github.min.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/fontawesome.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/brands.css">
<link rel="stylesheet" type="text/css" href="./theme/font-awesome/css/solid.css">
<link href="https://shanedowling.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Shane Dowling Atom">
<link href="https://shanedowling.com/feeds/all.rss.xml" type="application/rss+xml" rel="alternate" title="Shane Dowling RSS">
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'G-Z9P3V6D0SV', 'auto');
ga('send', 'pageview');
</script>
<meta name="author" content="Shane Dowling" />
<meta name="description" content="1)debug_print_backtrace() I use this one a lot, print a debug-style list of what was called to get thethe point where this function is called. Very, very useful. 2) __autoload() - Called when you attempt to load a class that hasn't been defined. the autoloader to attempt an import of xyz …" />
<meta name="keywords" content="">
<meta property="og:site_name" content="Shane Dowling"/>
<meta property="og:title" content="8 randomly useful php tricks"/>
<meta property="og:description" content="1)debug_print_backtrace() I use this one a lot, print a debug-style list of what was called to get thethe point where this function is called. Very, very useful. 2) __autoload() - Called when you attempt to load a class that hasn't been defined. the autoloader to attempt an import of xyz …"/>
<meta property="og:locale" content="en_US"/>
<meta property="og:url" content="./8-randomly-useful-php-tricks-1acfd89a3fb4.html"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="2010-02-22 00:00:00+00:00"/>
<meta property="article:modified_time" content=""/>
<meta property="article:author" content="./author/shane-dowling.html">
<meta property="article:section" content="Tech"/>
<meta property="og:image" content="/images/logo.png">
<title>Shane Dowling – 8 randomly useful php tricks</title>
</head>
<body class="light-theme">
<aside>
<div>
<a href="./">
<img src="/images/logo.png" alt="Shane Dowling" title="Shane Dowling">
</a>
<h1>
<a href="./">Shane Dowling</a>
</h1>
<p>Platform Engineering Manager</p>
<nav>
<ul class="list">
<li>
<a target="_self"
href="./pages/contact.html#contact">
Contact
</a>
</li>
<li>
<a target="_self"
href="./pages/now-page.html#now-page">
Now Page
</a>
</li>
<li>
<a target="_self"
href="./pages/statuslog.html#statuslog">
Statuslog
</a>
</li>
<li>
<a target="_self" href="https://hybridcloudshow.com/" >podcast</a>
</li>
<li>
<a target="_self" href="https://pemonthly.com/" >newsletter</a>
</li>
</ul>
</nav>
<ul class="social">
<li>
<a class="sc-github"
href="http://github.com/shano"
target="_blank">
<i class="fa-brands fa-github"></i>
</a>
</li>
<li>
<a class="sc-mastodon"
rel="me" href="http://social.lol/@sed"
target="_blank">
<i class="fa-brands fa-mastodon"></i>
</a>
</li>
<li>
<a class="sc-linkedin"
href="https://www.linkedin.com/in/shanedow/"
target="_blank">
<i class="fa-brands fa-linkedin"></i>
</a>
</li>
</ul>
</div>
</aside>
<main>
<article class="single">
<header>
<h1 id="8-randomly-useful-php-tricks-1acfd89a3fb4">8 randomly useful php tricks</h1>
<p>
Posted on Mon 22 February 2010 in <a href="./category/tech.html">Tech</a>
</p>
</header>
<div>
<p><strong>1)debug_print_backtrace()</strong>
I use this one a lot, print a debug-style list of what was called to get
thethe point where this function is called. Very, very useful.</p>
<p><strong>2) __autoload()</strong>
- Called when you attempt to load a class that hasn't been defined.
the autoloader to attempt an import of xyz.php. Probably not the best
technique for readability or clarity in code, but has it uses.</p>
<p><strong>3) ip2long()</strong>
Don't store IP addresses as strings on a db use this to store them as a
long.</p>
<p><strong>4) oString()</strong>
- If an object is ever used as a string, you can define what's returned
here. Again you can find it's uses once you realise these things are
possible. :)</p>
<p><strong>5) get_browser()</strong>
- Easily get your hands on the users browser-type. Some leave this
process to the browser end but can be useful to get this info server
side.</p>
<p><strong>6)</strong></p>
<p>More of a total dirty hack(come on, it's PHP). Having problems with
that annoying 'headers already sent' error. Don't bother to fix the
underlying problem, just omit the closing php tag! It's totally
valid(this list is really becoming things I hate about PHP….)</p>
<p><strong>7) natsort()</strong>
This will sort lists of things in ways humans will understand. Good idea
when displaying drop-down lists etc for users. Again, you might find a
use.:)</p>
<p><strong>8) metaphone()</strong>
Again one of those random things PHP does, you may never use this but
comparing words that sounds similar, this one's really obscure and I
honestly haven't actually found a use for it yet.:)</p>
<p>Take a look at the PHP magic methods for some other ideas. :)</p>
</div>
<div class="tag-cloud">
<p>
</p>
</div>
</article>
<footer>
<p>© </p>
<p>
Built with <a href="http://getpelican.com" target="_blank">Pelican</a> using <a href="http://bit.ly/flex-pelican" target="_blank">Flex</a> theme
</p></footer> </main>
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Blog",
"name": " Shane Dowling ",
"url" : ".",
"image": "/images/logo.png",
"description": ""
}
</script>
</body>
</html>