MBA 683 E-Business Technology --

Ref: PHP
Home    Site Map    Search    EhrlichOrg.com

Syllabus    Classes    References  Examples  Student Info    Guest Info

 

PHP References

The online manual is probably the best reference for PHP. There is a version with annotations by many different users. Sometimes these comments are very helpful and sometimes they are wrong or out of date. 

Online manual: www.php.net/manual/en/ or us2.php.net/manual/en/ 

Tips:

Parse errors, you may get a PHP parse error with a line number:
The line number refers to the PHP line, not counting any HTML lines in the file.
Use UltraEdit or another editor (FrontPage HTML view) that shows line numbers and allows you to go to a specific line. 
Check the line given for proper syntax.
The error may be before the line number given in the error message; for example, a missing semicolon (;). If the line number is the last line of your page, the problem may be with quotes or curly brackets.
Check for matched pairs of double quotes ("), single quotes('). In UltraEdit use Find to count the number of quotes, the number should be even.
Check for matched parentheses (()), braces or curly brackets ({}), and brackets ([]). In UltraEdit use the Match Brace function (control B) to display matches.
Make sure that each statement ends with a semicolon (;).
Make sure the conditional part of a while statement (in parentheses) does not end in a semicolon.
Check if statements, the condition part should be enclosed in parentheses (not curly brackets).  Any functions, like empty(), should have parentheses surrounding their arguments.
Avoid using 'class' as a variable name or associative array subscript, you may get strange errors. 
If you can't find the error:
Try commenting out sections of the code in order to isolate the error.
If the error is on lines that look correct, check the file using UltraEdit HEX Editing mode: spaces should be hex 20 characters, there should not be any hex A0 or hex 00 characters.
If you see your php code when you view a page or view source, make sure that you have named the page .php and not .htm or .php.htm. Also check that your .htaccess file has the correct contents, file name, and is in your public_html directory.
'Fatal Error: Call to undefined function: ()' may result if you put a $ in front of a function name.
The error 'Warning: Cannot send session cache limiter - headers already sent' may result from doing a session_register, or other session operation, following some static HTML (even blank lines) or other output. Session operations must come before any output.
Having trouble with PHP global variables? Make sure the list of global variables is separated by commas, not semi-colons (;).
If you are generating HTML tables that are not properly formed (for example, no </table>) you may not be able to see your output. Try changing the tags to @@table> and @@/table> or adding a border so the table info will be displayed by the browser.
There are certain reserved words you should avoid in PHP: 
Variable name $this 
Subscript of class as in a[class].
If you want to delete a Form Variable named $foo, use this command:
    unset($GLOBALS[foo]);

For More Information

For more information on PHP, see:

Zend Technologies www.zend.com 
Developer Shed www.devshed.com/Server_Side/PHP/ 
PHP Builder www.phpbuilder.com 
WebMonkey http://hotwired.lycos.com/webmonkey/programming/php/ (warning, some of this information is out of date)
PHP by Example Part I and Part II, Personalized Web Sites
PHP compared to other languages:
Server-side Scripting Languages compares PHP, Perl, Java servlets
Choosing the right server-side scripting language compares Perl, PHP, Python, Tcl, and Java servlets
Web Application Development with PHP 4.0 by Tobias Ratschiller and Till Gerken, New Riders, 2000. Not recommended unless you have a computer science background.
 
 

© 2001 by Chuck Ehrlich, all rights reserved.  Comments to webmaster.  Updated on October 21, 2001.