DOMDocument() constructor

Hi all,

I’m trying to run some php scripts in shell. part of the script needs the dom constructor:

$dom = new DOMDocument();

this works from a browser standpoint but when running in shell you get the error:

Warning: domdocument() expects at least 1 parameter, 0 given in

reading the php documentation they use arguments so following the example provided on the documentation:

$dom = new DOMDocument(‘1.0’, ‘UTF-8’);

gives me a new error.
Warning: domdocument() expects parameter 2 to be long, string given

which makes no sense since the documentation clearly states the second one is a string.

further research says that it is a conflict between php4 and php5 being installed at the same time. since dreamhost manages all those installs and i havent done any custom install of php, is there any way to rectify this problem?

php4 is default in shell.

To switch to php5 for shell, add the following to .bash_profile

export PATH=/usr/local/php5/bin:$PATH

Maximum Cash Discount on any plan with MAXCASH

Thanks for the reply.

So I put that into the shell and then restarted my session. After running phpinfo() it still says its running php 4.4.8

After the edit, you should be receiving returns like the following:

$ which php

$ php -v
PHP 5.2.6 (cli) (built: …

Maximum Cash Discount on any plan with MAXCASH

yep, i get those responses back.

still the script bombs out… i ended up putting


into the top of the file to force it to php5

But I’d really would like it to interpret it as php5 through the bash like you have tried to help me with.