Vivid Lust Posted February 22, 2008 Share Posted February 22, 2008 PHP Define: I've seen it around ... what is it and what does it do? An are there any tutorials with it??? Oh, the PHP net site really confuses me, so theres no point posting that. Thanks in advanced Jake! AKA Vivid Lust Quote Link to comment Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 It's not confusing when you take the time to read lol Defines a named constant at runtime Returns TRUE on success or FALSE on failure. <?php define("CONSTANT", "Hello world."); echo CONSTANT; // outputs "Hello world." echo Constant; // outputs "Constant" and issues a notice. define("GREETING", "Hello you.", true); echo GREETING; // outputs "Hello you." echo Greeting; // outputs "Hello you." ?> Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted February 22, 2008 Author Share Posted February 22, 2008 So they are basically variables? ??? Quote Link to comment Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 Exacly it's a way of making vars with out a $ into a simple way of explaining it lol Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted February 22, 2008 Author Share Posted February 22, 2008 Ok, thanks. Quote Link to comment Share on other sites More sharing options...
aschk Posted February 22, 2008 Share Posted February 22, 2008 No no, they're not variables at all, they're constants Once you've done DEFINE("name", "blah"); You CAN'T then to do name = "some other blah"; Quote Link to comment Share on other sites More sharing options...
jeremyphphaven Posted February 22, 2008 Share Posted February 22, 2008 Yes, let me interject here as well. A constant is something you want to define that WILL NEVER CHANGE through your entire script/app A good example might be: Take FORUMS for instance... in your preferences you set Date and Time. In the code, a constant... define("USERTIME", "-8"); // GMT-8 for Pacific time ... may be defined for use later. This will never change in your script once defined and the use of constants is definitely a methodical thing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.