PHP4 supports DOMDocument? My code says yes?
When I check phpinfo(), I see /usr/local/php4/lib/php.ini
That means PHP4, right?
But When I execute the line of code below, it returns PHP5. WTF? I thought PHP4 did not have the DOMDocument class. I need to test for PHP4 and do a workaround, but this specific test is confusing me. Is there another more foolproof way to check for PHP4 in script?
if (is_admin() && class_exists('DOMDocument')) {
echo "PHP开发者_开发知识库5";
} else {
echo "Awe PHP4";
}
The version of your PHP is listed right on top of any phpinfo()
output. You can also determine it by echoing phpversion()
or from CLI with php -v
.
Apart from that, no. PHP4 does not support DOMDocument
(at least not the one you are refering to). The old DOM XML extension has a similar named class though.
Try the following:
echo extension_loaded('domxml') ? 'old' : 'new';
phpinfo() is a cool function :)
edit, lots of similar functions here http://www.php.net/manual/en/ref.info.php
you seem like you'd be interested in phpversion() and version_compare()
The correct way to check your PHP version from phpinfo()
is to read the header at the very top, but when doing checks in PHP code, checking php_version()
is the way to do. There is also a predefined constant PHP_VERSION
.
Well if phpinfo says you run php5 you are running php5. assuming by php_info you mean phpinfo.
you may wanna check the function phpversion
The path you are referring to is just the configured config file which could be anything.
You probably updated and kept it ages ago.
精彩评论