note 110271 added to phar.webphar
| From: | James | Date: | Sat, 06 Oct 2012 19:55:22 +0000 |
| Subject: | note 110271 added to phar.webphar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191161@lists.php.net to get a copy of this message | ||
It seems that calling Phar::webPhar() from inside a function is a bad idea. Doing so will cause
global variables in included files to not be global. For instance, do NOT try this:
<?php
$phar = new Phar('test.phar.php');
$phar['test.php'] = '<?php
$FOO = "globals work";
function test() {
global $FOO;
echo "test: $FOO\n";
}
test();
?>';
$phar->setStub('<?php
function _bootstrap() {
Phar::webPhar();
}
_bootstrap();
__HALT_COMPILER(); ?>');
?>
The output will be "test:", not "test: globals work".
----
Server IP: 69.147.83.199
Probable Submitter: 76.120.71.66
----
Manual Page -- http://www.php.net/manual/en/phar.webphar.php
Edit -- https://master.php.net/note/edit/110271
Del: integrated -- https://master.php.net/note/delete/110271/integrated
Del: useless -- https://master.php.net/note/delete/110271/useless
Del: bad code -- https://master.php.net/note/delete/110271/bad+code
Del: spam -- https://master.php.net/note/delete/110271/spam
Del: non-english -- https://master.php.net/note/delete/110271/non-english
Del: in docs -- https://master.php.net/note/delete/110271/in+docs
Del: other reasons-- https://master.php.net/note/delete/110271
Reject -- https://master.php.net/note/reject/110271
Search -- https://master.php.net/manage/user-notes.php