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 Link to comment https://forums.phpfreaks.com/topic/92468-php-define/ 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." ?> Link to comment https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473731 Share on other sites More sharing options...
Vivid Lust Posted February 22, 2008 Author Share Posted February 22, 2008 So they are basically variables? ??? Link to comment https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473738 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 Link to comment https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473740 Share on other sites More sharing options...
Vivid Lust Posted February 22, 2008 Author Share Posted February 22, 2008 Ok, thanks. Link to comment https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473749 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"; Link to comment https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473752 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. Link to comment https://forums.phpfreaks.com/topic/92468-php-define/#findComment-473758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.