Hi Tobiasz,
Thanks for your reply. I was actually trying out inserting PHP code
earlier today, but I ran into an obscure issue where the document
would come out blank depending on the size of the string. I just
looked into it more to try to narrow it down using the below example.
Also, on a side note, I did find a way to use eval without writing it
into a file by adding '?>' to the beginning of my eval string, though
not sure if that's the recommended thing to do:
-------------------------------------------------
$doc = phpQuery::newDocument('<div id="content"></div>');
$content_string = str_repeat('a', 99988);
pq('#content')->php('echo '.var_export($content_string, true));
eval('?>'.$doc->php());
-------------------------------------------------
On my system, I don't get any output from the eval line, but if I
change the str_repeat line to 99987 (1 character less), then I get
output. Looking at the phpQuery.php file, it seems to be caused by
the function markupToPHP() in the first call to preg_replace_callback
(). For some reason, that line is setting $content to NULL if the
length of content is above a certain length. Not sure if it's an
issue with your regexp or with PHP itself or an issue related to my
environment. I am running PHP 5.2.9 on CentOS 5 though I ran the same
below simplified test on PHP 5.2.9 on Windows and got the same results
there too:
-------------------------------------------------
$content = "<div id=\"content\"><php><!-- echo '".str_repeat('a',
99988)."' --></php></div>";
$content = preg_replace_callback(
'@<php>\s*<!--(.*?)-->\s*</php>@s',
create_function('$m',
'return "<'.'?php ".htmlspecialchars_decode($m[1])." ?'.'>";'
),
$content
);
var_dump($content);
-------------------------------------------------
For me, $content is NULL, but if I change the str_repeat to be 99987,
then $content is populated.
Any help you could provide would be appreciated.
Thanks,
Ryan