????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.55 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/tokenizer/tests/ |
Upload File : |
--TEST--
Reconstructing a script using token_get_all()
--SKIPIF--
<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
--FILE--
<?php
$phpstr = '
<?php
// A php script to test token_get_all()
/* a different
type of
comment */
// a class
class TestClass {
public function foo() {
echo "Called foo()\n";
}
}
$a = new TestClass();
$a->foo();
for ($i = 0; $i < 10; $i++) {
echo "Loop iteration $i\n";
}
?>';
$token_array = token_get_all($phpstr);
$script = "";
// reconstruct a script (without open/close tags) from the token array
foreach ($token_array as $token) {
if (is_array($token)) {
if (strncmp($token[1], '<?php', 5) == 0) {
continue;
}
if (strncmp($token[1], '?>', 2) == 0) {
continue;
}
$script .= $token[1];
} else {
$script .= $token;
}
}
var_dump($script);
eval($script);
?>
--EXPECT--
string(259) "
// A php script to test token_get_all()
/* a different
type of
comment */
// a class
class TestClass {
public function foo() {
echo "Called foo()\n";
}
}
$a = new TestClass();
$a->foo();
for ($i = 0; $i < 10; $i++) {
echo "Loop iteration $i\n";
}
"
Called foo()
Loop iteration 0
Loop iteration 1
Loop iteration 2
Loop iteration 3
Loop iteration 4
Loop iteration 5
Loop iteration 6
Loop iteration 7
Loop iteration 8
Loop iteration 9