array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'phar.canwrite.php', 1 => 'Phar::canWrite', ), 'up' => array ( 0 => 'class.phar.php', 1 => 'Phar', ), 'prev' => array ( 0 => 'phar.cancompress.php', 1 => 'Phar::canCompress', ), 'next' => array ( 0 => 'phar.compress.php', 1 => 'Phar::compress', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/phar/Phar/canWrite.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 1.0.0)
Phar::canWrite — Returns whether phar extension supports writing and creating phars
This static method determines whether write access has been disabled in the system php.ini via the phar.readonly ini variable.
Example #1 A Phar::canWrite() example
<?php
if (Phar::canWrite()) {
file_put_contents('phar://myphar.phar/file.txt', 'hi there');
}
?>