本文整理汇总了PHP中dir::path方法的典型用法代码示例。如果您正苦于以下问题:PHP dir::path方法的具体用法?PHP dir::path怎么用?PHP dir::path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dir
的用法示例。
在下文中一共展示了dir::path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save($file_name = false, $use_backup = false, $suffix = false, $use_override = false, $only_modified = false)
{
$line_separator = sys::line_separator();
$path_array = array();
if ($file_name === false) {
$file_name = $this->file_name;
}
$path_array[] = $this->root_dir;
if ($use_override) {
$path_array[] = 'override';
}
if (is_string($use_override) && $use_override == 'append') {
$file_name .= '.append';
}
if ($suffix !== false) {
$file_name .= $suffix;
}
$originalfile_name = $file_name;
$backupfile_name = $originalfile_name . sys::backup_filename();
$file_name .= '.tmp';
$file_path = dir::path(array_merge($path_array, $file_name));
$original_file_path = dir::path(array_merge($path_array, $originalfile_name));
$backup_file_path = dir::path(array_merge($path_array, $backupfile_name));
$fp = @fopen($file_path, 'w+');
if (!$fp) {
debug::write_error("Failed opening file '{$file_path}' for writing", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
return false;
}
$write_ok = true;
$written = fwrite($fp, "<?php /* #?ini charset=\"" . $this->charset . "\"?{$line_separator}{$line_separator}");
if ($written === false) {
$write_ok = false;
}
$i = 0;
if ($write_ok) {
foreach (array_keys($this->block_values) as $block_name) {
if ($only_modified) {
$group_has_modified = false;
if (isset($this->modified_block_values[$block_name])) {
foreach ($this->modified_block_values[$block_name] as $modified_value) {
if ($modified_value) {
$group_has_modified = true;
}
}
}
if (!$group_has_modified) {
continue;
}
}
$written = 0;
if ($i > 0) {
$written = fwrite($fp, "{$line_separator}");
}
if ($written === false) {
$write_ok = false;
break;
}
$written = fwrite($fp, "[{$block_name}]{$line_separator}");
if ($written === false) {
$write_ok = false;
break;
}
foreach (array_keys($this->block_values[$block_name]) as $block_var) {
if ($only_modified) {
if (!isset($this->modified_block_values[$block_name][$block_var]) || !$this->modified_block_values[$block_name][$block_var]) {
continue;
}
}
$var_key = $block_var;
$var_value = $this->block_values[$block_name][$block_var];
if (is_array($var_value)) {
if (count($var_value) > 0) {
foreach ($var_value as $var_array_key => $var_array_value) {
if (is_string($var_array_key)) {
$written = fwrite($fp, "{$var_key}" . "[{$var_array_key}]={$var_array_value}{$line_separator}");
} else {
$written = fwrite($fp, "{$var_key}" . "[]={$var_array_value}{$line_separator}");
}
if ($written === false) {
break;
}
}
} else {
$written = fwrite($fp, "{$var_key}" . "[]{$line_separator}");
}
} else {
$written = fwrite($fp, "{$var_key}={$var_value}{$line_separator}");
}
if ($written === false) {
$write_ok = false;
break;
}
}
if (!$write_ok) {
break;
}
++$i;
}
}
if ($write_ok) {
//.........这里部分代码省略.........
示例2: path
function test_path()
{
$this->assertEqual(dir :: path(array('test')), 'test');
$this->assertEqual(dir :: path(array('test', 'wow')), 'test' . dir :: separator() . 'wow');
$this->assertEqual(dir :: path(array('test', 'wow/')), 'test' . dir :: separator() . 'wow');
$this->assertEqual(dir :: path(array('test'), true), 'test' . dir :: separator());
$this->assertEqual(dir :: path(array('test', 'wow'), true), 'test' . dir :: separator() . 'wow' . dir :: separator());
}