what is the advantage of using
define (VAR, "this and that");
over
$VAR = "this and that" ;
is one method frowned upon? depreciated?
or is it down to personal choice?
regards
StevenJ
define is used when you are creating CONSTANTS.
$VAR is used when you are creating ordinary VARIABLES.
doh!
somthing that simple never occured to me!
thanks.......
Constants cannot be changed. Hence the term constant. These are great for storing values that must stay the same throughout the entire application.
I use constants for all my application settings, connection details etc.
Adding to what Thorpe says, constants are always available within functions and methods without having to declare them global before use. It would be great if they were expanded beyond ints and strings so you could use things like objects and arrays with them. Try to have a convention for them, too. I always use caps with underscores for word speparation with constants.