PHP Classes

test code does not work?

Recommend this page to a friend!

      CSS Query  >  All threads  >  test code does not work?  >  (Un) Subscribe thread alerts  
Subject:test code does not work?
Summary:parse errir in CSSQuery.php on line 362
Messages:5
Author:Franc
Date:2009-08-02 06:58:15
Update:2009-08-06 02:26:20
 

  1. test code does not work?   Reply   Report abuse  
Picture of Franc Franc - 2009-08-02 06:58:15
I have just download and test this code and get a parse error:

Parse error: syntax error, unexpected T_VARIABLE in /var/www/html/temp/css/CSSQuery.php on line 362

php is php-5.1.6-23.2.el5_3 on Centos 5 system

  2. Re: test code does not work?   Reply   Report abuse  
Picture of Morten Sigsgaard Morten Sigsgaard - 2009-08-02 16:43:23 - In reply to message 1 from Franc
Yea same here from the version i downloaded, actually its not just the test code as the error is thrown from the CSSQuery object code.

This is the line in question:
if ($element instanceof DOMElement $elem->hasAttribute("id") && $elem->getAttribute("id") == $id)

It is quite easy to fix though, T_VARIABLE says something about thruth, and we're in an if-sentence. Add the && (and) after DOMElement, though also, 'element' is not in any scope of the function, lets call it 'elem' and we're on the roll again:

if ($elem instanceof DOMElement
&& $elem->hasAttribute("id")
&& $elem->getAttribute("id") == $id)

Congratz on the current secondplace to the author. Hope this is the one and only error, since ive been looking for this feature for a while.

  3. Re: test code does not work?   Reply   Report abuse  
Picture of Sam S Sam S - 2009-08-05 14:33:47 - In reply to message 1 from Franc
@Franc

I apologize for this terrible oversight in the syntax, I have corrected the problem and I have also altered the attribute filtering mechanism to support the entire operator. I hope that you find this class useful.

  4. Re: test code does not work?   Reply   Report abuse  
Picture of Sam S Sam S - 2009-08-05 14:34:34 - In reply to message 2 from Morten Sigsgaard
@Morten

I hope that you will let me know if you do find any errors so that I can correct them. :)

  5. Re: test code does not work?   Reply   Report abuse  
Picture of baochungit baochungit - 2009-08-06 02:26:20 - In reply to message 1 from Franc
Thank you! it works very good now