views:

55

answers:

3
$XMLFormatedString .= "<Filter id='" .= .$row->id. .="' name='" .= .$row->label. .="'><Label>" .= .$row->label. .="</Label></Filter>";
+1  A: 

You have multiple syntax errors:

 .= "<Filter id='" .= .$row->id.

Should be:

 .= "<Filter id='".$row->id.

etc...

Adam
+2  A: 

The left hand side of an assignment operator like .= needs to be a variable. But in this case "<Filter id='" is not a variable.

I guess you meant the normal string concatenation operator .:

$XMLFormatedString .= "<Filter id='" . $row->id . "' name='" . $row->label . "'><Label>" . $row->label . "</Label></Filter>";
Gumbo
+4  A: 

You can't chain the .= operator like that. it's also not nessecary in this case, you can just use the . operator after the first one:

$XMLFormatedString .= "<Filter id='" .$row->id. "' name='" .$row->label."'><Label>" .$row->label."</Label></Filter>";

also, whatever you're trying to do, it looks like a bad idea. you should use something like PHP DOMDocument to write XML.

GSto
+1. Especially for the DomDocument bit... But fyi: you can chain the `.=` operator in general. `$f = 'f'; $o = 'o'; $f .= $o .= 'obar';` will end with `$f == 'foobar'` and `$o == 'oobar'`. But you can't have a static string (non-variable) anywhere to the left of the `.=`...
ircmaxell