By the tests the problem is in the character +
It is deleted in the final code because it is not correctly escaped.
A code that works here in your case is this:
$Start = microtime(true);
ini_set('max_execution_time', 5);
$Code = <<<'Code'
<?php
for($i=0; $i < 300; $i++) {
echo $i . "\n";
};
?>
Code;
include_once 'data://text/plain,' . urlencode($Code);
echo microtime(true) - $Start;
?>
And here using what you mentioned about php://memory
<?php
$Start = microtime(true);
ini_set('max_execution_time', 5);
$Code = <<<'Code'
<?php
for($i=0; $i < 300; $i++) {
echo $i . "\n";
};
?>
Code;
$fp = fopen('php://memory', 'rw');
fwrite($fp, urlencode($Code)); // escapando corretamente os caracteres
fseek($fp, 0); // Retornando o ponteiro ao inicio do bloco de memória
include_once 'data://text/plain,' . stream_get_contents($fp); // incluindo como um arquivo
echo microtime(true) - $Start;
?>
the allow_url_include directive is enabled?
– Marcos Regis
yes, it is activated...
– Slowaways
Curious. I had never seen this type of code, but when performing the tests I understood why of the infinite loop.
$i
can never be increased because it seems that its scope does not exist. Useecho $i
and set the maximum running time to 5 seconds to check.– Marcos Regis
Only 0.. variable appears
$i
is not being written...– Slowaways