Parse error: parse error, expecting `T_STRING' in C:\\wamp\\www\\pmh\\lib\\PEAR\\XML\\Tree\\Node.php on line 112
Plz help me solve this Error
/**
* clone node and all its children (recursive)
*
* @return object reference to the clone-node
*/
function &clone() {
$clone=new XML_Tree_Node($this->name,$this->content,$this->attributes);
$max_child=count($this->children);
for($i=0;$i<$max_child;$i++) {
$clone->children[]=$this->children[$i]->clone();
}
You’ve probably left a string open somewhere above that point in your code
Let’s read this part again carefully: “somewhere above that point in your code”. That point being line 112 function &clone(). You haven’t posted any of your code from ABOVE this point so I can only speculate on what is up there. That is why I posted a code example of the type of error you are looking for. This is why I used the word probably.
Did you actually go and look at your code to see if I was right?
If you believe line 112 is the only possible cause of the problem you obviously haven’t got much experience debugging PHP, and should be a lot less hasty to post condescending comments like “Plz dont just write whatever comes in your head”.
If you think that then point out where. As far as i know, none of string are left incomplete.Plz dont just write whatever comes in your head. Only reply if you really know the solution. Plz dont just guess.
It clearly says line 112 which is function &clone() {
so I couldn’t understand whats wrong in this line.
He can’t point that out as it isn’t in the code you’ve posted. Your function seems fine, so what cranial-bore suggests that the error may be before the code you posted may indeed be the case.
When PHP indicates an error on line this-and-that, it may be before that line, but the interpreter doesn’t choke on the line that actually contains the error, but on the next line.
That being said, could you post the complete file?
PS. You can use [noparse]
[/noparse] tags to get PHP color highlighted code, instead of using [noparse]
You’ve probably left a string open somewhere above that point in your code (or forgotten a ; to end a statement)
e.g.
$something = 'This is a string that never ends
/**
* clone node and all its children (recursive)
*
* @return object reference to the clone-node
*/
function &clone() {
$clone=new XML_Tree_Node($this->name,$this->content,$this->attributes);
$max_child=count($this->children);
for($i=0;$i<$max_child;$i++) {
$clone->children[]=$this->children[$i]->clone();
}