Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

define variables

Status
Not open for further replies.

curvv

IS-IT--Management
Jan 11, 2001
103
ZA
hi,

I know it's not really necessary to define all variables but i'd like to do so anyway. when i use var $myvar; i get a parse error. how else can i define a variable?

thanx ######## CtN ########
 
With PHP, you don't use the keyword "var" to declare a variable. All you need to do to initialize a variable is set it. Thus you could do something like:

$mystringvar = '';

$mynumericvar = 0;

PHP does have a syntax for defining constants, though ( which can be very useful:

define("CONSTANT_NAME", "constant_value");

Now the constant CONSTANT_NAME can be used anywhere in your code, inside or outside of functions. Constants have a truly global scope, and they can't "accidentally" have new values assigned to them. For this reason they are good for such things as passwords, directory paths, etc... things that you wouldn't want a querystring hacker to mess with. -------------------------------------------

"Now, this might cause some discomfort..."
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top