...

View Full Version : Question about variables



mic2100
05-08-2006, 10:24 AM
I have been using php for about 12 months and i have never had to declare a variable as either a Interger or String etc, how come i don't have to do this in php when i have used other languages i have always had to declare them first. Y is php different.:confused:

harsh789
05-08-2006, 11:58 AM
In PHP this is done automatically. PHP does not support explicit type definition in variable declaration. In other languages like c it is required to define before using the variable. It's type is determined in PHP by the context in which that variable is used.

For Ex.
If you assign a string value to variable $temp, it becomes a string. If you then assign an integer value to it, it becomes an integer.

MRMAN
05-08-2006, 12:23 PM
harsh789. On a different note all together where did you get the images for you search button and search header on your site?

degsy
05-08-2006, 02:07 PM
There are still variable eval functions
http://uk.php.net/manual/en/function.is-int.php

And there are a few cast functions
http://www.zend.com/manual/language.types.integer.php
http://www.zend.com/manual/language.types.string.php#language.types.string.conversion



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum