Blog by Sumana Harihareswara, Changeset founder
Dipping My Toes Into PHP
Hi, reader. I wrote this in 2014 and it's now more than five years old. So it may be very out of date; the world, and I, have changed a lot since I wrote it! I'm keeping this up for historical archive purposes, but the me of today may 100% disagree with what I said then. I rarely edit posts after publishing them, but if I do, I usually leave a note in italics to mark the edit and the reason. If this post is particularly offensive or breaches someone's privacy, please contact me.
This week, alumni like me get to spend time at Hacker School. Since I work on MediaWiki-related documentation and I've never programmed in PHP before, I decided to start understanding just enough PHP to be able to read it better. Jordan Orelli from Etsy, a fellow alumnus, was kind enough to give me several pointers, and to especially help me understand how a PHP programmer's experience differs from my experience as a Python programmer.
I have learned, for instance:
php -aat the command line.
apt-get install php5is a good way to install PHP.
which the server will execute, thanks to something like Apache's
<p><?php echo "I am leet!"; ?></p>
mod_phpplugin, and then send to the browser as the HTML
<p>I am leet!</p>
mod_php, you execute it within a sandbox just for that HTTP request! And that means that "the global namespace" really means "the global namespace for the current HTTP request" so "global" sort of has a different meaning, and thus I understand better why people are more okay with using "global" variables and the "argh, global data is bad" aversion is weaker in the world of PHP programming.
But you also cannot share state this way! So you should use caches & the database & job queues & other persistence layers.
index.phpplus query parameters, e.g. https://www.mediawiki.org/w/index.php?title=Performance_guidelines . So, if you're using Apache,
.htdocsfiles (need to double-check this), which contain just a giant list of "if this then that" regexes, to rewrite the URLs of HTTP request headers.
14 May 2014, 16:42 p.m.
14 May 2014, 19:28 p.m.
C. Scott Ananian
21 May 2014, 19:01 p.m.