PHP Intro

Writing your own functions

By admin | Posted in PHP Intro

"All custom functions should start with xxx_ so that the developer knows a native PHP function is not being called.* where xxx == your initials, or the project's initials, or ..." An example custom function style: function pwb_my_function($parameter1, $parameter2) { global $an_outside_variable; .... ...
Read more »

Syntax Check a PHP Pgm

By greg | Posted in PHP Intro

if you have error_reporting turned on: @ini_set('display_errors', '1'); error_reporting(E_ALL); # (E_ALL ^ E_NOTICE) or everything: (E_ALL) and you still get nothing but a blank page ... then, by all means, your next step might be to take the syntax check option built into PHP! From a linux/unix command line (terminal session), run...
Read more »

PHP Intro

By greg | Posted in PHP Intro

PHP is becoming the most widely-used general-purpose scripting language*, especially suited for Web development. It is, in fact, the programming component of the LAMP environment: Linux, Apache, MySql, Php. PHP is surprisingly more popular than Microsoft's own ASP web scripting language! PHP runs lot faster than ASP...
Read more »

php, Arrays

By greg | Posted in PHP Intro

Array keys start from 0, not 1. In an associative array a key is associated with a value. An array in PHP is actually an ordered map. (each key is mapped to a value). array values can be other arrays, trees and multidimensional arrays are also possible. A value can be any PHP type. A key may be...
Read more »

php Number Formatting

By greg | Posted in PHP Intro

the number_format() function can be used within an echo statement ex: number_format($ttl,2) and includes commas $number=2512589.66785; echo "Number = $number "; echo " The value after formating = ".number_format($number); // The above line will display 2,512,590...
Read more »

php basic String functions

By greg | Posted in PHP Intro

strcmp, substring, strtoupper, strtolower, str_replace, addslashes, trim, strstr, strpos, str_repeat, strrev, explode, implode, chunk_split, . . . If you need to compare two strings, the strcmp() function performs a case-sensitive binary comparison of two strings, returning a negative value if the first is "less" than the second, a positive value if it's...
Read more »