flash gordon Posted September 26, 2009 Share Posted September 26, 2009 Okay, so the docs say define() defines a constant value in php but it is also global as well? How does that define method work? I specifically asking for stuff like define("AMFPHP_BASE", realpath(dirname(dirname(dirname(__FILE__)))) . "/"); require_once(AMFPHP_BASE . "shared/app/BasicGateway.php"); require_once(AMFPHP_BASE . "shared/util/MessageBody.php"); but now other class don't define() AMFPHP_BASE but are able to have access to the constant. how it is typically used? Quote Link to comment https://forums.phpfreaks.com/topic/175565-define-and-require_once/ Share on other sites More sharing options...
mikesta707 Posted September 26, 2009 Share Posted September 26, 2009 define(constant name, value) thats pretty much it Quote Link to comment https://forums.phpfreaks.com/topic/175565-define-and-require_once/#findComment-925117 Share on other sites More sharing options...
hamza Posted September 26, 2009 Share Posted September 26, 2009 define supported in (PHP 4, PHP 5) purpose define — Defines a named constant Description bool define ( string $name , mixed $value [, bool case_insensitive = false ] ) Defines a named constant at runtime. name The name of the constant. value The value of the constant; only scalar and null values are allowed. Scalar values are integer, float, string or boolean values. It is possible to define resource constants, however it is not recommended and may cause unpredictable behavior. case_insensitive If set to TRUE, the constant will be defined case-insensitive. The default behavior is case-sensitive; i.e. CONSTANT and Constant represent different values. Report a bug Return Values Returns TRUE on success or FALSE on failure. Quote Link to comment https://forums.phpfreaks.com/topic/175565-define-and-require_once/#findComment-925124 Share on other sites More sharing options...
redarrow Posted September 26, 2009 Share Posted September 26, 2009 Simple way to understand. The database connection is a constant. Also i think define was always supported, no matter what php version. Quote Link to comment https://forums.phpfreaks.com/topic/175565-define-and-require_once/#findComment-925163 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.