- PHP stands for PHP: Hypertext Preprocessor (its a recursive acronym)
- PHP is a scripting language which is interpreted instead of compiled
- PHP is developed using syntax from C, Perl and Java including some new creations aswell.
- PHP is currently on its 5th major release, however PHP 4 is still the most used version.
- More information or installation help can be found at [url="http://www.php.net"]PHP.net[/url]
In order for the PHP interpreter to start parsing PHP script, you must first define a start and stop point for PHP instructions. A number of tags can be used, depending on their avaliability. The tags supported by PHP are:
- The normal php tags to close
- Short PHP tags
- HTML type script tags <script language="php"> and (seldom used)
- ASP type tags
echo and print
PHP has two constructs which output expressions to a browser. Neither of these are functions and therefore parenthesis isn't required:
Code: Select all
<?php
print("Hello");
//works the same as
print "Hello";
?>Satements
A statement is a command which the interpreter must execute. This could be an expression, call to an object or function or numerous other constructs built into PHP. A simple example statement is:
Code: Select all
echo "This is a statement";Variables
To make PHP similar to almost every other language PHP facilitates the use of variables. Variables can store one value at a time (including an array) and can be changed numerous times in the execution of a script (they can be varied...hence the name). In PHP variables are prefixed with the dollar sign ($) and are case sensitive, so $variable is different from $Variable. Also, unlike certain languages (eg VB) PHP doesn't require the variable to be declared prior to use.
Constants
The opposite of a variable is a constant. Once defined it cannot be changed during the execution of a script. A constant must be created using the define() function, here is an example:
Code: Select all
<?php
define("CONSTANT", 17);
echo CONSTANT;
?>Hopefully that shows you the basics of the PHP language. I've tried to make this as clear as possible, but if something is unclear - just ask /good.gif' class='bbc_emoticon' alt='(Y)' />
