本文整理汇总了PHP中FileManager::write方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::write方法的具体用法?PHP FileManager::write怎么用?PHP FileManager::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testScan
public function testScan()
{
$content = 'test';
$path = __DIR__ . '/test/';
$filePath = $path . 'test.txt';
$this->manager->write($filePath, $content);
$this->assertEquals($filePath, $this->manager->scan([$path], ['txt'], [__DIR__ . '/folder/'])[0]);
}
示例2: write
/**
* Writes schema file from object or options.
*
* @param array|object $object Schema object or options array.
* @param array $options Schema object properties to override object.
* @return mixed False or string written to file.
*/
public function write($object, $options = array())
{
if (is_object($object)) {
$object = get_object_vars($object);
$this->build($object);
}
if (is_array($object)) {
$options = $object;
unset($object);
}
extract(array_merge(get_object_vars($this), $options));
$out = "class {$name}Schema extends CakeSchema {\n\n";
if ($path !== $this->path) {
$out .= "\tpublic \$path = '{$path}';\n\n";
}
if ($file !== $this->file) {
$out .= "\tpublic \$file = '{$file}';\n\n";
}
if ($connection !== 'default') {
$out .= "\tpublic \$connection = '{$connection}';\n\n";
}
$out .= "\tpublic function before(\$event = array()) {\n\t\treturn true;\n\t}\n\n\tpublic function after(\$event = array()) {\n\t}\n\n";
if (empty($tables)) {
$this->read();
}
foreach ($tables as $table => $fields) {
if (!is_numeric($table) && $table !== 'missing') {
$out .= $this->generateTable($table, $fields);
}
}
$out .= "}\n";
$file = new FileManager($path . DS . $file, true);
$content = "<?php \n{$out}";
if ($file->write($content)) {
return $content;
}
return false;
}
示例3:
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//include whois class
include __DIR__ . '\\src\\FileManager.php';
$fileManager = new \FileManager();
$path = '/home/username/somedir/file.txt';
// or
// $path = 'C:\hello\test.txt';
$content = 'blablabla';
$result = $fileManager->write($path, $content);
var_dump($result);