PHP Intro

PHP INTRO, debugging, html quotes, email, closing tags, security, if, cookies, alt. syntax

December 12, 2016

updated 2020-05-11. PHP is now the most popular servers-side scripting language in the world. It is, in fact, the programming component of the “LAMP” environment: Linux, Apache, MySql, Php and is built in to all major linux distributions. PHP is surprisingly more popular than Microsoft’s own ASP web scripting language! PHP initially started on Linux/unix environment but today there are more PHP developers on...

Read more »

php basic String functions

June 6, 2016

updated 2020-08-28 strlen, strcmp, substring, strtoupper, strtolower, str_replace, addslashes, trim, strstr, strpos, str_repeat, strrev, explode, implode, chunk_split, . . .   string length $length = strlen($str); an empty string if( empty($string) ) : A variable is empty if it’s undefined, null, false, 0 or an empty string.   substring $str = "abcdefgh"; echo substr($str, 1); // bcdefgh echo substr($str, 3); // defgh echo substr($str,...

Read more »

basic loops in PHP

February 10, 2013

Loops execute a block of code a specified number of times, or while a specified condition is true. for for ($i = 1; $i

Read more »

php, Arrays

March 12, 2012

updated 2016-04-09 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...

Read more »

PHP: Writing your own functions

December 16, 2011

“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 »

Syntax Check a PHP Pgm

May 14, 2010

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, Rounding, and Incrementing

February 10, 2010

updated 2019-09-15 Checking ctype_digit() only checks strings from the manual: $strings = array('1820.20', '10002', 'ws123'); foreach ($strings as $testcase) { if (ctype_digit($testcase)) { echo "The string $testcase consists of all digits.\n"; } else { echo "The string $testcase does not consist of all digits.\n"; } } The above example will output: The string 1820.20 does not consist of all digits. The string 10002 consists...

Read more »