array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), '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' => 'ja', '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 — phar 拡張モジュールが phar の書き込みや作成をサポートしているかどうかを返す
このstaticメソッドは、書き込みアクセスが php.ini の phar.readonly で無効にされているかどうかを調べます。
例1 Phar::canWrite() の例
<?php
if (Phar::canWrite()) {
file_put_contents('phar://myphar.phar/file.txt', 'hi there');
}
?>