PHP Introduction

Just a few beginner notes on the PHP language.

Unlike CGI scripts, which require you to write code to output HTML, PHP lets you embed PHP code in regular HTML pages, and execute the embedded PHP code when the page is requested.

<?php ... php code goes here ... ?>

Ok, how about a web site for online documentation:

Every PHP statement ends in a semi-colon. This convention is identical to that used in Perl, and omitting the semi-colon is one of the most common mistakes newbies make. That said, it is interesting to note that a semi-colon is not needed to terminate the last line of a PHP block.

// this is a single-line php comment
/* and this is a
multi-line php
comment */

Some of this information was derived from the following web site:

Here is a quote from that site:

Within the PHP script itself, the sky’s the limit – your script can perform calculations, process user input, interact with a database, read and write files… Basically, anything you can do with a regular programming language, you can do inside your PHP scripts.

Alternatives to using PHP for web development:

  • ASP and ASP.NET
  • Perl
  • Java
  • JavaScript
  • Python
  • Ruby and Ruby on Rails
  • ColdFusion

PHP code can be mixed in with your regular HTML code but needs to be delimited properly so that the web server can process it and translate it to the proper HTML output to be sent back out to the client.

<h2>PHP Code</h2>
<?php echo "Have a nice day." ?>
<p>Mix your php code in with your html</p>

In the WordPress environment of writing and editing your own pages and blog posts, you cannot simply insert PHP code into your pages and posts using the php syntax mentioned above. What you are reading now is a post in WordPress that has a title PHP 101. If I insert properly delimited PHP code in this post using the Text editor, it will be ignored! The question is where do you write PHP code in the WordPress environment? You write it in PHP Template files. WordPress Themes are made of a series of template files. Each WordPress Theme uses their own set of template files to render output.