Saturday, October 25, 2008

Self-Referencing

In the Web application often we need self referencing URL to refer path current Script. Marginally this implementation step can through 2 approach, namely apply superglobal $_ SERVER and function getenv().

echo $_SERVER['PHP_SELF']; echo $_SERVER['SCRIPT_NAME']; echo $_SERVER['REQUEST_URL'] echo getenv['SCRIPT_NAME'] echo getenv['REQUEST_URL']
Different with other element, REQUEST_URL will return query string (if founded. For applied inveterate approach is element PHP_SELF.

Read More “Self-Referencing”  »»

Thursday, October 16, 2008

array base technique

To make easy using array, be better if we comprehend Array Base Technique must be first. Create Array Array in PHP grouped to become two type, indexed and associative. Array Indexed is array who’s the key like in the form of integer, normally started from 0. Array associative used string as key. You Can Create array with two models. Number one uses language construction array() and square bracket sintax.
$arr1 = array(‘a’,’b’,’c’); print_r($arr1); $arr2[] = ‘a’; $arr2[] = ‘b’; $arr2[] = ‘c’; Print_r($arr2);
Create array associative you must do that with same way. But in here you must specified of base key.
$arr3 = array(‘a’ => ‘A’, ‘b’ => ‘B’, ‘c’ => ‘C’); print_r($arr3); $arr4[‘a’] = ‘A’; $arr4[‘b’] = ‘B’; $arr4[‘c’] = ‘C’; print_r($arr4);

Read More “array base technique”  »»