Information Technology Reference
In-Depth Information
15
Before writing any PHP code, you should also check that your favorite text editor or integrated
development environment (IDE) supports PHP code highlighting and the like. With the popularity of
PHP, it should not be difficult to find an editor that includes this support.
Integrated Development Environments
If you're new to programming, you might not know what an integrated development environment
is. In traditional programming, this is an application that includes:
a text editor for writing source code
a language compiler (sometimes more than one) to translate the source code into a form the
computer can understand
a debugger, to find causes for problems in the code
a tool to automate the build process for programming projects involving more than one
program
Microsoft Visual Studio, C++ Builder, and Delphi are well-known Windows IDEs. Eclipse is a terrific
cross-platform IDE.
When you're programming in PHP or other web-oriented languages, you can use any one of several
IDEs, many of them free of charge and/or open source. These include Adobe Dreamweaver and
ActiveState Komodo in Windows, KDevelop, Quanta Plus, and Anjuta in Linux, with NetBeans and
Aptana as cross-platform applications.
Writing PHP Scripts: Basic Syntax
You've already written your first PHP script—the one-line test.php script you used to test your
installation in the last section. There's more to learn, of course, and you will do that in this section.
The PHP interpreter basically treats any documents fed to it as text and echoes back the contents,
unless it finds code set between special opening and closing tags. Part of what makes PHP effective
in WordPress is that you can embed your code in an HTML page and PHP won't touch your HTML.
It will only process your PHP code, and the end result is a final HTML document with the PHP code
replaced with the resulting output.
In Chapter 14, “Style Sheets for Building Themes,” we talked about the importance of the semi-
colon in writing CSS. It is equally important, indeed essential, in PHP.
Variables, Strings, and Arrays
Before we begin, let's define three essential types of data used and referred to in PHP. If you think
of a programming language as having a grammar, these are the most important nouns in this
language.
Variables are used in PHP to store information in memory that the script might need. The way vari-
ables work in PHP was basically stolen from another scripting language, Perl. They are identified by
a $ and are not strictly typed like variables in other languages. This means a variable can hold a
number, a string, or anything else that you might want to alias.
Search WWH ::




Custom Search