Results 1 to 10 of 10
Thread: Variables in PHP
01-02-2006, 03:24 PM #1ctaxiGuest
Variables in PHP
Variables in PHP are quite different from compiled languages such as C and Java. Why ?
01-02-2006, 04:12 PM #2MerrillGuest
Because their weakly typed nature, which in short means you donít need to declare variables before using them, you donít need to declare their type and, as a result, a variable can change the type of its value as much as you want.
01-02-2006, 08:12 PM #3rustyGuest
Variables in PHP are preceded with a $ sign, and similar to most modern languages, they can start with a letter (A-Za-z) or _(underscore) and can then contain as many alphanumeric characters and underscores as you like.
01-02-2006, 08:33 PM #4ctaxiGuestOriginally Posted by Merrill
01-03-2006, 03:13 AM #5
- Join Date
- Oct 2004
well explained . by exmple you mean a code? here is a simple code
$simpletext ="Hi This is Me";
You can also check out the manual of in the variables section by visiting this url
http://us3.php.net/language.variables█ For Reliable and Affordable Web Hosting Packages, Please visit kooshin.com
█ KooshinDesigns.com- Version One Online
█ ArticleStorage.com- Your #1 Resource For Articles
█ 4Ulyrics.com -- The Lyrical Hideout, For Sale - Email me for details.
01-03-2006, 07:08 AM #6MerrillGuest
$PI = 3.14;
$radius = 5;
$circumference = $PI * 2 * $radius; // Circumference = p * d
You can see that none of the variables are declared before they are used. Also, the fact that $PI is a floating-point number, and $radius (an integer) is not declared before they are initialized.
01-03-2006, 01:29 PM #7ctaxiGuest
Thanks kooshin and Merrill for examples and URL's.
01-25-2006, 06:06 PM #8sofy60Guest
it's a completely different language
03-18-2006, 08:19 PM #9ligeshGuestOriginally Posted by ctaxi
IN php, like all scrpting languages, variables are dynamic and you can treat them agains as variables. For instance, you can do $$vv which would give you the value of the variable by the name of value contained in vv. Thi is not possible in statically typed languages.
03-27-2006, 04:46 PM #10joey101Guest
Also with PHP vars, the type of the value is irrelevant.
$var = 5;
$var2 = "2";
$var3 = $var + $var2;