本文整理汇总了PHP中gpFiles::FileStart方法的典型用法代码示例。如果您正苦于以下问题:PHP gpFiles::FileStart方法的具体用法?PHP gpFiles::FileStart怎么用?PHP gpFiles::FileStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpFiles
的用法示例。
在下文中一共展示了gpFiles::FileStart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveData
/**
* Save array to a $file location
*
* @param string $file The location of the file to be saved
* @param string $varname The name of the variable being saved
* @param array $array The value of $varname to be saved
* @param array $meta meta data to be saved along with $array
*
*/
public static function SaveData($file, $varname, $array, $meta = array())
{
$file = self::FilePath($file);
if (gp_data_type === '.json') {
$json = self::FileStart_Json($file);
$json[$varname] = $array;
$json['meta_data'] = $meta;
$content = json_encode($json);
} else {
$content = gpFiles::FileStart($file);
$content .= gpFiles::ArrayToPHP($varname, $array);
$content .= "\n\n";
$content .= gpFiles::ArrayToPHP('meta_data', $meta);
}
return gpFiles::Save($file, $content);
}
示例2: SaveData
/**
* Save array to a $file location
*
* @param string $file The location of the file to be saved
* @param string $varname The name of the variable being saved
* @param array $array The value of $varname to be saved
* @param array $meta meta data to be saved along with $array
*
*/
public static function SaveData($file, $varname, $array, $meta = array())
{
global $dataDir;
if (strpos($file, $dataDir) !== 0) {
$file = $dataDir . '/data/' . ltrim($file, '/') . '.php';
}
if (gp_data_type === '.json') {
$file = substr($file, 0, -4) . '.gpjson';
$json = self::FileStart_Json($file);
$json[$varname] = $array;
$json['meta_data'] = $meta;
$content = json_encode($json);
} else {
$content = gpFiles::FileStart($file);
$content .= gpFiles::ArrayToPHP($varname, $array);
$content .= "\n\n";
$content .= gpFiles::ArrayToPHP('meta_data', $meta);
}
return gpFiles::Save($file, $content);
}
示例3: SaveArray
/**
* Save array(s) to a $file location
* Takes 2n+3 arguments
*
* @param string $file The location of the file to be saved
* @param string $varname The name of the variable being saved
* @param array $array The value of $varname to be saved
*
*/
function SaveArray()
{
global $gpversion;
$args = func_get_args();
$count = count($args);
if ($count % 2 !== 1 || $count < 3) {
trigger_error('Wrong argument count ' . $count . ' for gpFiles::SaveArray() ');
return false;
}
$file = array_shift($args);
$file_stats = array();
$data = '';
while (count($args)) {
$varname = array_shift($args);
$array = array_shift($args);
if ($varname == 'file_stats') {
$file_stats = $array;
} else {
$data .= gpFiles::ArrayToPHP($varname, $array);
$data .= "\n\n";
}
}
$data = gpFiles::FileStart($file, time(), $file_stats) . $data;
return gpFiles::Save($file, $data);
}