Re: Error with DOMDocument in php's functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mauricio Muriel wrote:
> Hi Guys,
> 
> I want to ask you about this problem:
> 
> I have a FUNCTION where is a DOMDocument element, that DOMDocument element
> is "Load" from a string (With well formed XML structure) stored in a param,
> this is code:
> 
> <?php
> 
> function xml_match($columns,$text,&$result)
> {
> ...
> /* Some code */
> ...
>  $doc = new DOMDocument();
>  $doc->loadXML($text);
> 
> ... /* REST of function's code */
> 
> Now in the line number 63 (in the function) I have this code:
> 
> ...
> Line 62: $arrDocChilds = $doc->childNodes;
> Line 63: if ($arrDocChilds->item($i)->nodeType != '3')
> ...
> 
> I have that function in one .php file (the function is the unique code in
> that file, and the file name is xml_match.php); Now, the problem is, when I
> try to execute that file from command line, I'm getting this error:
> 
> [admin@server xml]$ php xml_match.php
> PHP Parse error:  parse error in
> /var/www/vhosts/default/htdocs/spytest/share/xml/xml_match.php on line 63
> Content-type: text/html
> X-Powered-By: PHP/4.3.2
> 
> My question is, why is php launching this error, if the code is in a
> function that is not called?
> 
> Regards
> 
> Mauricio M.
> 

Well, PHP is parsing the file for syntax whether the code actually
executes it or not.  PHP has no idea whether you are actually going to
call the function or not.  This will happen if you include the file in
another one even if the function is never called.

It's hard to see the parse error without your code.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux