本文整理匯總了PHP中JFile::Write方法的典型用法代碼示例。如果您正苦於以下問題:PHP JFile::Write方法的具體用法?PHP JFile::Write怎麽用?PHP JFile::Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JFile
的用法示例。
在下文中一共展示了JFile::Write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doExecute
/**
* Entry point for the script
*
* @return void
*
* @since 1.0
*/
public function doExecute()
{
jimport('joomla.filesystem.file');
if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) {
$configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php';
if (is_writable($configfile)) {
$config = file_get_contents($configfile);
//Do a simple replace for the CMS and old school applications
$newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config);
// Newer applications generally use JSON instead.
if (!$newconfig) {
$newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config);
}
if (!$newconfig) {
$this->out('This application does not have an offline configuration setting.');
} else {
JFile::Write($configfile, &$newconfig);
$this->out('Site is offline');
}
} else {
$this->out('The file is not writable, you need to change the file permissions first.');
$this->out();
}
} else {
$this->out('This application does not have a configuration file');
}
$this->out();
}
示例2: shSaveFile
function shSaveFile($shFileName, $fileData)
{
if (empty($shFileName)) {
return;
}
$fileIsThere = file_exists($shFileName);
if (!$fileIsThere || $fileIsThere && is_writable($shFileName)) {
if (is_array($fileData)) {
$fileData = implode("\n", $fileData);
//make sure we write a string
}
JFile::Write($shFileName, empty($fileData) ? '' : $fileData);
}
}