WordPress is written in the PHP scripting language, and, therefore, much of what users contribute to the software in the way of themes and plug-ins is written in the same language. In this chapter, you'll learn a little bit about the language, along with its relationship to WordPress and the MySQL database. You'll find out where PHP fits in with theme creation. We conclude with writing WordPress plug-ins with PHP and getting them into the WordPress Plugin Directory.
PHP is the result of another lazy programmer's effort to simplify his life. Back in 1994, Rasmus Lerdorf wanted to eliminate some of the drudgery associated with updating his personal web page. Lerdorf wrote some Perl scripts to generate HTML tags based on some code programmed in the C language. In June 1995, he announced the existence of the Personal Home Page (PHP) tools, version 1.0, in a Usenet CGI newsgroup. Those tools have since evolved into a full-fledged scripting language with a powerful engine, Zend, and a large community of developers hacking the code. You can read more about the history of PHP at http://php.net/history.
Many people are put off by any kind of programming. However, millions of people who are non-college graduates or liberal arts majors, who don't like math, who would never wear a pocket protector or fix their eyeglasses with electrical tape, or who otherwise consider programming to be something they do not do have learned the necessities to program in WordPress. It's fine to get a book on PHP or WordPress programming, take a course, and/or find a supportive and knowledgeable friend if you feel the need. However, you might be surprised how far you get with the introduction and orientation given here and with existing WordPress plug-ins as grist for your mill.
The coding might seem intimidating at first, but many who were initially frightened have learned by example and experimentation, supported by the WordPress community. You won't break WordPress — many more talented, and with far worse intentions, than you have tried and failed. Don't be afraid to dive in.
The PHP Home Page at www.php.net defines PHP as "a widely used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Much of its syntax is borrowed from C, Java, and Perl with a couple of unique PHP-specific features thrown in." It is open source, so anyone can contribute to its development, and works from the web server to deliver pages. As you'll see later in the chapter, PHP often pulls data out of relational database management systems such as MySQL and PostgreSQL to display web pages that look no different from pages coded in standard HTML.
Although you really don't need to worry about it to work in WordPress, be aware that PHP has its own plug-in library. As you get deeper into PHP, you'll want to check out the PHP Extension and Application Repository (PEAR) at http://pear.php.net and the PHP Extension Community Library (PECL) at http://pecl.php.net.
The PECL library is a set of modules that can link into the language's core. The new functions they provide are then available as any of PHP's built-in functions.
PEAR is a collection of reusable, open source code for use in your PHP applications. The code is organized as collections of files (or packages) that act as wrappers, giving convenient access to various PHP functions or extending PHP in some way.
Both PECL modules and PEAR packages can be installed using the php5-pear command-line utility. Calling pear without any arguments displays a list of commands pear understands. The install argument followed by the package or module name installs it; the uninstall argument similarly uninstalls the component.
Was this article helpful?
Simple secrets to turn your computer into a cash machine. Successful Bloggers know that with the right money making opportunities blogs can become cash generating machines. If you want to start a profitable blog, or profit from an existing blog, you need to know this information. Start blogging for cash today and learn everything you need to know to profit from your blog.