Mark Baker Mark Baker - 6 months ago 9
PHP Question

libxml constants are accessible, yet don't register as defined constants

According to the PHP documentation, there are a number of constants defined when the libxml extension is enabled.

These are accessible in the code, so something like

var_dump(LIBXML_DTDLOAD);


will return a value of
int(4)
(no problem so far, that's exactly what I expect to see)

What puzzles me is if I do

echo var_dump(defined(LIBXML_DTDLOAD));


I get a
bool(false)
returned....

So how can I access the constant and see its value if it isn't (apparently) defined? Or why does
defined()
return a false for a constant that clearly is defined?

Demo

jbe jbe
Answer

You didn't quote the constant name

var_dump(defined('LIBXML_DTDLOAD')); // bool(true)
Comments