This is a guest post about PHP basics and might get a little bit more technical than my average post. That is why I brought someone in who could actually go through PHP easily to help those interested in getting into the guts of your WordPress site to make basic changes to improve your blog. Remember this is for PHP basics and to check out Chris’s link below if you have hard-hitting questions.

Andy

PHP Basics for WordPress Bloggers

This blog covers some basics of PHP that will help WordPress bloggers in better management of their blogs. It is assumed that the user has basic programming knowledge of C or C++. So let us get started with it.

What is PHP: All the WebPages are sent in the form of HTML to any computer. Pure html pages are completely static and look similar to every viewer. Suppose you want to make some dynamic additions to the page so the page would always show the current date. This could be achieved using PHP. PHP is server side scripting language i.e. it is processed by your server and is used extensively by every web development company for creating websites. The Server reads PHP content, does the needful and sends it to your browser. However, PHP is not sent to the browser. The PHP is evaluated, converted into HTML and then sent to the browser. This is why the index.php file is not in HTML format.

How to insert PHP into HTML code: The PHP code should open with <?php and closed with ?>. You must enter all the PHP code inside these tags and you can do it as many times as you like on a page. To catch any future errors in the code you must leave proper comments in your code. In PHP, two of the most common ways to leave comments are // syntax and the /* comment*/ syntax. See a few PHP files and you will understand their usage. It has been noticed that programmers working in a PHP development company usually see it as an unnecessary activity but every great programmer understands the importance of comments and uses them properly.

Variables: You must be aware that variables are used to hold data which could be comprised of number, string, array etc. The variables start with a dollar sign ($) at the starting. To keep it simple, just use letters and numbers in your variable names. Variable can be created by assigning values to them. However, strings values should be assigned like ‘value’ or “value”. It should also be remembered that every line ends with a semicolon (;) just like in the old days.

Conditional Statements: Conditional statements are used to check a condition and repeat some selected code multiple number of times depending upon the result of the condition checked. These are also referred as special functions. Some of the most frequently used conditional statements are if, else, elseif, for, while and foreach. Users having programming knowledge of C and C++ will easily understand their usage. Look at some examples or a PHP code and you will understand their exact syntax for usage in PHP. Others need to get a little programming knowledge and then return back here.

Functions in PHP: We can only talk about the usage of existing functions. For creating new functions readers are requested to read an advanced tutorial. Functions are divided into two types; the one that RETURN a value and the one that PRINT (or echo) a value. The former type of functions can be used in conditional statements.

For example, is_home{} returns TRUE value when the viewer is on the home page and FALSE when not on the blog’s main page. the_ content{} function does not return any value but prints HTML. For example, <?php the_content{};?> code will make all the page content appear if it is inserted into a theme file. The latter type of functions should not be used in conditional statements as they will always evaluate to false because the_content{} function returns no value.

That’s it. That is all you need to know to start playing with PHP on your wordpress blog. Your programming skills will enhance as you move along and keep practicing it. However, for complex requirements and projects you can always hire a PHP programmer from any web development or Php development company.

About the Author: Chris Miller is a web developers @ a leading Php development company, Xicom which provides web application development services, software development, IT outsourcing services online marketing (seo/ppc/smo) & BPO.  Custom Web Application developments service from a leading web development company.