Thursday, November 29, 2007

PHP ...Lesson Three

Hey
let's Start

Variables in PHP
Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive, so $myvar is different from $myVar.

A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
Example :

Image Hosting


PHP Superglobals
Superglobals are variables that available anywhere in the program code. They are :
$_SERVERVariables set by the web server or otherwise directly related to the execution environment of the current script. One useful variable is $_SERVER['REMOTE_ADDR'] which you can use to know you website visitor's IP address
Image Hosting

Variable Scope
The scope of a variable is the context within which it is defined. Basically you can not access a variable which is defined in different scope.
The script below will not produce any output because the function Test() declares no $a variable. The echo statement looks for a local version of the $a variable, and it has not been assigned a value within this scope. Depending on error_reporting value in php.ini the script below will print nothing or issue an error message.
Image Hosting


Have a nice day

Related Posts by Categories



Widget by Scrapur

0 comments: