Hey every one . I need your help . I am new to programming in php so i want to know what is 'define ' statement used for and how to use it and please give me some examples. I looked in w3schools but i did not find it .
Thanks for your help .

8 Years
Discussion Span
Last Post by rch1231

You set constants by using the define statement. The format is
For instance, to set a constant with the company name, use the following
define(“COMPANY”,”My Fine Company”);
Use the constant in your script wherever you need your company name:
When you echo a constant, you can’t enclose it in quotes. If you do, you
echo the constant name, instead of the value. You can echo it without any-
thing, as shown in the preceding example, or enclosed in parentheses.

You can use any name for a constant that you can use for a variable. Constant
names are not preceded by a dollar sign ($). By convention, constants are given
names that are all uppercase, so you can easily spot constants, but PHP itself
doesn’t care what you name a constant. You don’t have to use uppercase, it’s
just clearer. You can store either a string or a number in it.
The following statement is perfectly okay with PHP:
define (“AGE”,29);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.