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

It's as if what doesn't handle it at all. define doesn't return anything accept true/false whether it successfully declared the constant or not. What exactly are you trying to do?

It's as if what doesn't handle it at all. define doesn't return anything accept true/false whether it successfully declared the constant or not. What exactly are you trying to do?

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.

Yes. It should return boolean false. What are you getting instead? What is the output of:

var_dump(EW_IS_WINDOWS);

Yes. It should return boolean false. What are you getting instead? What is the output of:

var_dump(EW_IS_WINDOWS);

define("EW_IS_WINDOWS", (strtolower(substr(PHP_OS, 0, 3)) === 'win'), TRUE);
print EW_IS_WINDOWS."<= output";

output:
1<= output

define("EW_IS_WINDOWS", (strtolower(substr(PHP_OS, 0, 3)) === 'wi'), TRUE);
print EW_IS_WINDOWS."<= output";

output:
<= output

Not to be rude but I didn't say print, I said var_dump. That tells you the type along with the value so you would see.
boolean(true)
or
boolean(false)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.