More PHP information will be appearing here over the coming weeks. Keep checking back to see what is new, and let us know if there is anything you specifically wish to see here (i.e. more reference stuff, code examples, working demo’s). The PHP information displayed here relates to PHP 5 and above unless stated otherwise.

For a quick reference of all PHP functions click here. Click to the quick links directly below, or by browse the PHP documentation further down the page.

Some preliminaries

PHP Comments

Ok lets kick off this section and add some examples (albeit simple ones – bear with us!). To comment single lines of PHP code use double forward slashes like so:

If you need to comment over several lines, or comment out a block of code use:

String literals

In PHP you can specify string content by enclosing it within single or double quotes.

'; echo "Text = $text
"; ?>

The output from the code snippet above is:

[remix][php] $text = ‘Hello’; echo ‘Text = $text
‘; echo “Text = $text
“; [/php][/remix]

As you can see, variables inside single quotes are treated as string literals, meaning the name of the variable is displayed on the screen not the value. However variables enclosed in double quotes are interpreted so that the variable value is displayed. Single quotes should be used wherever possible as there is a slight overhead in using double quotes, due to the fact the string has to be parsed first for any variables inside the string. For most PHP scripts the difference in performance would be negligible but if you had a function that operated on thousands of strings at a time then it might pay to optimise your usage of quotes!

Leave a Reply

Your email address will not be published.