O
O
Optimus2015-09-28 16:53:26
PHP
Optimus, 2015-09-28 16:53:26

Why is phar not being created?

Set write permissions phar.readonly = 0 in php.ini. Php 5.3.3 Registered Stream Filters zlib.*, bzip2.*
Creation, code:

$hello = "Hello!";
$phar = new Phar('test.phar');
$phar[hello.txt] = "$hello";

Execution result:
Notice: Use of undefined constant hello - assumed 'hello' in /var/www/user/data/www/site.ru/folder/phar_create.php on line 9
Notice: Use of undefined constant txt - assumed 'txt ' in /var/www/user/data/www/site.ru/folder/phar_create.php on line 9
What are the constants? Where?
But the test.phar file appears in a folder on the server. When trying to read:
Warning: file_get_contents(phar://test.phar/hello.txt): failed to open stream: phar error: "hello.txt" is not a file in phar "test.phar" in /var/www /user/data/www/site.ru/folder/phar_echo.php on line 7
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2015-09-28
Pyan @marrk2

What are the constants? Where?

Hello and txt constants in the line: $phar[hello.txt]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question