hi all,
im new to php and im stuck with a "constant" problem.
i was studying a code snippet and trying to creat a constant with define() like this:
define("ABC",1,TRUE).
i dont understand why it results nothing if the second parameter is 0.
The consant type is boolean and it works fine if the parameter is
1, but if it is 0, it seems as if it doesnt handle it at all.
thanks
constant by define
Moderator: General Moderators
Re: constant by define
What do you mean "handle"? What code are you using to check whether ABC "works fine"?
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Re: constant by define
Constant is just that... a constant value... not a boolean check....
can we see your code please?
can we see your code please?
Re: constant by define
this is what i want to figure out:
define("EW_IS_WINDOWS", (strtolower(substr(PHP_OS, 0, 3)) === 'win'), TRUE);
if im not mistaken, "EW_IS_WINDOWS" returns true if the operating system is Win OS, but what if it is not.
when i changed 'win' to 'wi', print EW_IS_WINDOWS returned nothing. it should return false, shouldnt it.
define("EW_IS_WINDOWS", (strtolower(substr(PHP_OS, 0, 3)) === 'win'), TRUE);
if im not mistaken, "EW_IS_WINDOWS" returns true if the operating system is Win OS, but what if it is not.
when i changed 'win' to 'wi', print EW_IS_WINDOWS returned nothing. it should return false, shouldnt it.
Re: constant by define
the way PHP handles it is that if you print a boolean false value, it prints nothing. that does not meant the value is not there or is 'not handled'. if the values is true it prints a '1'. if you want to see the actual type and value do a var_dump. you will see then either boolean values.szita1 wrote:this is what i want to figure out:
define("EW_IS_WINDOWS", (strtolower(substr(PHP_OS, 0, 3)) === 'win'), TRUE);
if im not mistaken, "EW_IS_WINDOWS" returns true if the operating system is Win OS, but what if it is not.
when i changed 'win' to 'wi', print EW_IS_WINDOWS returned nothing. it should return false, shouldnt it.
Code: Select all
define("EW_IS_WINDOWS", (strtolower(substr(PHP_OS, 0, 3)) === 'win'), TRUE);
var_dump(EW_IS_WINDOWS);