I am experiencing a very strange kind of encoding problem i don\'t really understand and never had before. I am using PHP 5.5 on an Ubuntu machine just for the info.
Not an answer but too long for a comment:
Could you please try
', $s, ''; for($i=0; $i';
'; for($i=0; $i';
in the place where you had ? What's the output of that?