I’m quite new to php, and I can’t get this to work, and I don’t understand why I can’t..
I am using NetBeans and XAMPP locally, but I have a server “slot” at school where I upload my webpages for public.
Basically, given this code
<?php
echo "1";
$dom = new DOMDocument();
echo "2";
?>
When I run this file through XAMPP locally, it prints out “12” as it should.
But when I copy the .php file to my server, which works with everything else, it only prints out “1”. It fails before it gets to “2”. My conclusion is that it won’t instantiate DOMDocument. How can that be? Locally i have php version 5.3.8, and on the server, it’s only 5.1.6. Is this the problem?
It seemed to me like DOMDocument was supported since 5.0, but I might be wrong about that..
Anyway, I do not have permission to update this version to test this, and I can’t find any information about supporting DOM in earlier versions.
Or have I forgotten something? I had kind of the same problem with JSON which isn’t supported in 5.1.6, and then I could include some (“upgrade.php”) file that I put next to index.php, and it worked. Any suggestions like this? Or any ideas at all?
Note that you should upgrade PHP, but that’s not the issue. You don’t have libxml or don’t have php-xml installed on your server. In Fedora-based linux, it doesn’t come with the default install of PHP. Run
yum install php-xmlto get it. That will auto-install its primary dependency, libxml.