Difference between revisions of "Editing PHP"

From Zen Cart(tm) Wiki
Jump to: navigation, search
m (Reverted edits by NxjTjc (Talk); changed back to last version by Allcanadiansearch.ca)
Line 1: Line 1:
''This article is intended for people who need to learn about PHP.''
'''Read the manual:'''
* [http://www.php.net/manual/en/index.php PHP manual]
** [http://www.php.net/manual/en/getting-started.php Getting started with PHP]
** [http://www.php.net/manual/en/langref.php PHP language reference]
*** [http://www.php.net/manual/en/language.basic-syntax.php Basic syntax]
*** [http://www.php.net/constants Constants]
First, get a text editor with syntax highlighting. This will help you spot syntax or "parse" errors. [http://notepad-plus.sourceforge.net/ Notepad++] is one free editor with syntax highlighting. Others include [http://www.crimsoneditor.com/ Crimson Editor] and [http://www.xtort.net/xtort/xint.php Xint].
All text must be written within either two single quotes or two double quotes, for example:
<pre>echo "This text is enclosed within two double quotes.";
echo 'This text is enclosed within two single quotes (apostrophes).';</pre>
If you want to use an apostrophe as a part of your text and you're also using apostrophes to enclose the text, you must ''escape'' it. Escaping a character in PHP means putting a backslash in front of it.
For example:
<pre>echo 'If we hadn\'t escaped apostrophes in this text, we\'d get a parse error.';</pre>
If you use double quotes to mark some text, you would have to escape any of those in your text;
<pre>echo "This is a piece of text enclosed within \"double quotes\".";</pre>
When editing Zen Cart&trade;, you will see a lot of [http://www.php.net/constants constants]. Example:
<pre>define('CONSTANT_EXAMPLE', 'This text is now stored inside a constant named "CONSTANT_EXAMPLE".');</pre>
As you can see from the above example, [http://www.php.net/define define()] is the PHP function that creates constants. PHP [http://www.php.net/manual/en/language.functions.php functions] can be identified by their parantheses, eg. "define()". [http://www.php.net/manual/en/functions.arguments.php Parameters/arguments] can be passed within the parantheses, but that depends on each separate function. [http://www.php.net/quickref.php List of all PHP functions.]

Revision as of 00:38, 5 December 2007