Nette\Utils\FileSystem::write PHP Метод

write() публичный статический Метод

Writes a string to a file.
public static write ( $file, $content, $mode = 438 ) : void
Результат void
    public static function write($file, $content, $mode = 0666)
    {
        static::createDir(dirname($file));
        if (@file_put_contents($file, $content) === FALSE) {
            // @ is escalated to exception
            throw new Nette\IOException("Unable to write file '{$file}'.");
        }
        if ($mode !== NULL && !@chmod($file, $mode)) {
            // @ is escalated to exception
            throw new Nette\IOException("Unable to chmod file '{$file}'.");
        }
    }

Usage Example

Пример #1
1
 /**
  * backup single database table to file
  *
  * @param string $table
  * @param string $path
  */
 public function backupTableToFile(string $table, string $path)
 {
     $sql = $this->getHeader();
     $sql .= $this->backupTable($table);
     FileSystem::createDir($path);
     $path .= '/' . $table . '_' . date('Y-m-d_H-i-s') . '.sql';
     FileSystem::write($path, $sql);
 }
All Usage Examples Of Nette\Utils\FileSystem::write