PHP Intro

basic loops in PHP

February 10, 2013
By

Loops execute a block of code a specified number of times, or while a specified condition is true. for for ($i = 1; $i $mon) { echo $key . ” – ” . $mon . ““; } output: 0 – January 1 – February … 11 – December $characters = “Porky Pig”; $characters = “Daffy Duck”; $characters = “Speedy Gonzales”; foreach ($characters as $key...

Read more »

php, Arrays

March 12, 2012
By

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 either an integer or a string....

Read more »

PHP INTRO, debugging, html quotes, closing tags, security

March 12, 2012
By

PHP is perhaps 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 on MS Windows and has more features and functionalities than Microsoft ASP. PHP is much more robust,...

Read more »

PHP: Writing your own functions

December 16, 2011
By

“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; .... return true; } functions with optional parameters suppose you are using a function with 1 param, and in some new cases,...

Read more »

Structured display of All Variables in memory

November 2, 2011
By

“The function, get_defined_vars(), returns a multidimensional array containing a list of all defined variables at that location in your program.” To get ALL variables, list ALL variables, display ALL variables, in memory and available at the point where you request it, your scope, (not just SESSION variables, everything … except private function variables – invisible/unavailable externally). To get more than just a string of...

Read more »

php basic String functions

November 10, 2010
By

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 the other ways around, and zero if both strings are “equal”. Take...

Read more »

Syntax Check a PHP Pgm

May 14, 2010
By

Be sure your error reporting is turned on: (for your testing copy or for your IP address) @ini_set('display_errors', '1'); error_reporting(E_ALL ^ E_NOTICE); If it is 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 php with its...

Read more »

php Number Formatting and Incrementing

February 10, 2010
By

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 ( without decimal and rounded) echo “<br> The value after formating = “.number_format($number,3); // Will display 2,512,589.668 ( with , after each thousand and // 3 digits after...

Read more »