Explore Ebooks
Categories
Explore Audiobooks
Categories
Explore Magazines
Categories
Explore Documents
Categories
• Common errors
• Coding standards
• Version control
• Developer education
define('STR_NBSP', ' ');
define('STR_BR_TAG', '<BR/>');
define('STR_BEGIN_TD', '<TD>');
define('STR_END_TD', '</TD>');
function change_to_lowercase($item,$key)
{
global $changes;
$changes[$key] = strtolower($item);
}
<?php
/**
* Description: Changes the case of text within tags <>
* Make sure the $argc and $argv variables are enabled.
* Invoke this script on CLI as follows:
* php <thisfilename.ext> file2Bparsed.ext
*
**/
$filename = $argv[1];
if (!file_exists($filename) || !is_readable($filename)) {
die("\nEnter a valid file\n");
}
$pattern = "/(<(\w+)>|<\/(\w+)>)/";
if (!$is_match) {
die("\nNo match found\n");
}
function foo(&$bar) {…
• (Excerpts)
• Formatting e.g.
– Always use long form PHP tags <?php ?>
– Two space indents throughout, NO HARD TABS
– …
• Naming
– Use camel caps for OO identifiers (classnames,
methods, member variables), like this:
$theVarCalledFoo
– …
PHP Quebec 2007 21
Standard - 2
• Comments
– Every file should have a header block
containing at a minimum…
– Single line comments are encouraged on
non-obvious code. These can also be
used to add "TODO", "DEBUG", and
"FIXME" items
–…
• Declare functions and classes in library files that do not have any execution
side effects besides possibly instantiating variables or defining constants.
• All code should run clean with error reporting turned up to E_ALL
• …