本文整理汇总了PHP中file_read函数的典型用法代码示例。如果您正苦于以下问题:PHP file_read函数的具体用法?PHP file_read怎么用?PHP file_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_read函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFile
/**
* @param $path
*
* @return array
*/
public function loadFile($path)
{
$content = trim(file_read($path));
$config = [];
if (!empty($content)) {
$config = Yaml::parse($content);
}
return $config;
}
示例2: loadFile
/**
* @param $path
*
* @return array
* @throws InvalidConfigFormatException
*/
public function loadFile($path)
{
$content = trim(file_read($path));
$config = [];
if (!empty($content)) {
$config = json_decode($content, true);
if (!is_array($config)) {
throw new InvalidConfigFormatException(s('JsonConfigDriver expects config at path %s to be a valid json file.', $path));
}
}
return $config;
}
示例3: test_directory
public function test_directory()
{
$dir1 = path(self::getDir(), 'dir_1/dir1');
$dir1_file = path($dir1, 'foo.txt');
$dir1_file_content = 'foo bar';
$dir2 = path(self::getDir(), 'dir_2/dir2');
$dir2_file = path($dir2, 'foo.txt');
$dir3 = path(self::getDir(), 'dir_3/dir3');
$dir3_file = path($dir3, 'foo.txt');
$dir4 = path(self::getDir(), '/dir_3/dir-3');
$dir4_name = 'dir-3';
$dir4_file = path($dir4, 'foo.txt');
$this->assertFalse(directory_exists($dir1));
directory_create($dir1);
file_write($dir1_file, $dir1_file_content);
$this->assertTrue(directory_exists($dir1));
$this->assertFalse(directory_exists($dir2));
directory_create(path($dir1, 'yolo'));
directory_copy($dir1_file, $dir2);
directory_delete($dir2);
directory_copy($dir1, $dir2);
$this->assertTrue(file_exists($dir2_file));
$this->assertEquals(file_read($dir1_file), file_read($dir2_file));
$this->assertFalse(directory_exists($dir3));
directory_move($dir2, $dir3);
$this->assertFalse(directory_exists($dir2));
$this->assertTrue(directory_exists($dir3));
$this->assertTrue(file_exists($dir3_file));
$this->assertEquals(file_read($dir1_file), file_read($dir3_file));
$this->assertFalse(directory_exists($dir4));
directory_rename($dir3, $dir4_name);
$this->assertTrue(directory_exists($dir4));
$this->assertFalse(directory_exists($dir3));
$this->assertTrue(file_exists($dir4_file));
$this->assertEquals(file_read($dir1_file), file_read($dir4_file));
$this->assertEquals(['foo.txt', 'yolo'], directory_list($dir1));
$this->assertEquals([path($dir1, 'foo.txt'), path($dir1, 'yolo')], directory_list($dir1, true));
$this->assertEquals([], directory_list('yada'));
$this->assertEquals(['dir_1', 'dir_2', 'dir_3'], directory_list(self::getDir()));
directory_delete(self::getDir());
$this->assertFalse(directory_exists(self::getDir()));
$this->assertEquals('dir1', directory_get_name($dir1));
$this->assertEquals(self::getDir() . '/dir_1', directory_get_parent($dir1));
}
示例4: verify_install
/**
* Verify that product can be installed
*
* @param string XML file to parse
*
* @return mixed true on success, error message on failure
*/
public function verify_install($productid)
{
$product_file = DIR . "/includes/xml/product-{$productid}.xml";
$xml = file_read($product_file);
try {
$this->parse($xml);
$this->import_dependencies();
} catch (vB_Exception_AdminStopMessage $e) {
$args = $e->getParams();
require_once DIR . '/includes/functions_misc.php';
$message = fetch_phrase($args[0], 'error', '', false, false, -1, false);
if (sizeof($args) > 1) {
$args[0] = $message;
$message = call_user_func_array('construct_phrase', $args);
}
return $message;
}
return true;
}
示例5: add_task
function add_task($task)
{
$tasks = unstock(file_read(DATA_FILE));
$tasks[] = $task;
file_append(DATA_FILE, stock($tasks), false);
}
示例6: sprintf
require_once DIR . '/includes/adminfunctions_language.php';
if (!($xml = file_read(DIR . '/install/vbulletin-language.xml'))) {
echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-language.xml') . '</p>';
print_cp_footer();
}
echo '<p>' . sprintf($vbphrase['importing_file'], 'vbulletin-language.xml');
xml_import_language($xml);
build_language();
build_language_datastore();
echo "<br /><span class=\"smallfont\"><b>{$vbphrase['ok']}</b></span></p>";
}
// #############################################################################
// import style
if ($vbulletin->GPC['step'] == 4) {
require_once DIR . '/includes/adminfunctions_template.php';
if (!($xml = file_read(DIR . '/install/vbulletin-style.xml'))) {
echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-style.xml') . '</p>';
print_cp_footer();
}
echo '<p>' . sprintf($vbphrase['importing_file'], 'vbulletin-style.xml');
xml_import_style($xml);
build_all_styles();
echo "<br /><span class=\"smallfont\"><b>{$vbphrase['ok']}</b></span></p>";
}
if ($vbulletin->GPC['step'] == 5) {
$gotopage = '../' . $vbulletin->config['Misc']['admincpdir'] . '/index.php';
echo '<p align="center" class="smallfont"><a href="' . $gotopage . '/index.php">' . $vbphrase['proceed'] . '</a></p>';
echo "\n<script type=\"text/javascript\">\n";
echo "window.location=\"{$gotopage}\";";
echo "\n</script>\n";
print_upgrade_footer();
示例7: badhook_check
/**
* Checks existince of a stupid vbcms bug that has been around since RC2
*
*/
function badhook_check()
{
if (file_exists(DIR . "/includes/xml/hooks_vbcms.xml")) {
$badhookfile = file_read(DIR . "/includes/xml/hooks_vbcms.xml");
if (strpos($badhookfile, "data_preparse_bbcode_video_start")) {
print_table_header("WARNING");
print_description_row("vBulletin contains a known bug that prevents AME from working. You must follow these steps or you may as well disable AME now");
print_description_row("1. Edit your <strong>includes/xml/hooks_vbcms.xml</strong> file");
print_description_row("2. Delete <strong><hook>data_preparse_bbcode_video_start</hook></strong> and save the file.");
print_description_row("3. Rebuild your hooks by browsing to your Plugin Manager, edit the <strong>AME - Auto Convert URLs</strong> hook and save (you don't need to change anything).");
print_description_row("You can read more about this issue here: <a href='http://www.vbulletin.com/forum/project.php?issueid=33859' target='_blank'>http://www.vbulletin.com/forum/project.php?issueid=33859</a>");
print_table_break();
}
}
}
示例8: file_read
// Проверка на наличие файла в папке
if (!check_file($edit_file, $files)) {
$errors[] = "Sorry, but file does not exist";
}
}
?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000">
<title>Просмотр</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="wrap">
<div class="container">
<h3>Просмотр текста</h3>
<div>
<?php
echo file_read($edit_file);
?>
</div>
<a class="btn btn-back" href="index.php">Вернуться на Главную</a>
</div>
</div>
</body>
</html>
示例9: file_prepend
/**
* Prepend contents to the beginning of file.
*
* @param $path
* @param $content
*
* @return bool
*/
function file_prepend($path, $content)
{
if (file_exists($path)) {
return file_write($path, $content . file_read($path));
}
return file_write($path, $content);
}
示例10: test_file_read_returns_null_for_not_existing_files
public function test_file_read_returns_null_for_not_existing_files()
{
$this->assertEquals(null, file_read('some_file'));
}
示例11: header
<?php
header("Content-type: text/html; charset=utf-8");
require 'connect.php';
//echo 'aaaaaa';
$i = 0;
$j = 0;
$file_r = file_read();
var_dump($file_r);
$file_name = explode("~", $file_r);
foreach ($file_name as $name_new) {
if (!strstr($name_new, ";")) {
$series_name = $name_new;
$query = "SELECT `series_id` FROM `disney_series` WHERE `series_name` LIKE '" . $series_name . "'";
echo $query . "<br>";
$result = mysql_fetch_object(mysql_query($query));
$series_id = $result->series_id;
} else {
if (strlen($name_new) > 4) {
$book_name = explode(";", $name_new);
foreach ($book_name as $name) {
if (strlen($name) > 4) {
if (strpos($name, "|")) {
$new_name = explode("|", $name);
$name_ch = trim($new_name[0]);
$name_en = addslashes(trim($new_name[1]));
if (strpos($new_name[2], "@")) {
$book_level = explode("@", $new_name[2]);
$level = trim($book_level[1]);
$audio = addslashes(trim($book_level[0]));
$img = addslashes(trim($book_level[0]));
示例12: import_product_mobile
protected function import_product_mobile($data, $product)
{
switch ($product) {
case 'vbblog':
$file = 'vbulletin-mobile-style-blog.xml';
break;
case 'vbcms':
$file = 'vbulletin-mobile-style-cms.xml';
break;
default:
$this->skip_message();
return;
}
$perpage = 1;
$startat = intval($data['startat']);
require_once DIR . '/includes/adminfunctions_template.php';
$importfile = '';
if (!($xml = file_read(DIR . '/install/' . $file))) {
// output a mobile style not found error
$this->add_error(sprintf($this->phrase['vbphrase']['file_not_found'], $file), self::PHP_TRIGGER_ERROR, true);
return;
}
if ($startat == 0) {
$this->show_message(sprintf($this->phrase['vbphrase']['importing_file'], $file));
}
$info = xml_import_style($xml, -2, -2, '', false, 1, false, $startat, $perpage, 0, $file);
if (!$info['done']) {
$this->show_message($info['output']);
return array('startat' => $startat + $perpage);
} else {
$this->show_message($this->phrase['core']['import_done']);
}
}
示例13: waterImage
/**
* 添加水印图片
* @param array $config
*/
public function waterImage(array $config = array())
{
$config = array_merge($this->water, $config);
if (!$config['status']) {
return false;
}
if (file_exist($config['image'])) {
$watermark = $this->imagine->open($config['image']);
//本地水印图片
} else {
$path = C('TMPL_PARSE_STRING');
$file = str_replace($path[UPLOAD_PATH], UPLOAD_PATH, $config['image']);
if (!file_exist($file)) {
return false;
}
$waterImage = file_read($file);
$watermark = $this->imagine->load($waterImage);
//水印图片
}
$water = $watermark->getSize();
//水印图片尺寸
$position = $this->getPosition($water->getWidth(), $water->getHeight(), $config['position'], $config['x'], $config['y']);
//如果水印不能完整显示,则不添加水印
list($width, $height) = $this->getSize();
if ($water->getWidth() + $position->getX() > $width) {
return false;
}
if ($water->getHeight() + $position->getY() > $height) {
return false;
}
$format = $this->getFormat();
if ($this->lib != 'gd' && strtolower($format) == 'gif') {
$this->image->layers()->coalesce();
foreach ($this->image->layers() as $frame) {
$frame->paste($watermark, $position);
}
} else {
$this->image->paste($watermark, $position);
}
}
示例14: watermark
/**
* 添加水印
*/
public function watermark($config = array())
{
$config = !empty($config) ? $config : C('IMAGE_WATER_CONFIG');
if (!$config['status']) {
return false;
}
$position = $config['position'] ? $config['position'] : 9;
//水印位置 1-9九宫格
$x = $config['x'];
$y = $config['y'];
if ($config['type']) {
if (!$config['image']) {
return false;
}
$path = C('TMPL_PARSE_STRING');
$water = file_read(str_replace($path[UPLOAD_PATH], UPLOAD_PATH, $config['image']));
unset($path);
if (!$water) {
return false;
}
$this->add_watermark($water, $x, $y, $position, false);
} else {
$water = $config['text'];
if (!$water) {
return false;
}
$this->add_text($water, $x, $y, $position, 0, array('font' => COMMON_PATH . 'Font/yuppy.otf', 'font_size' => !empty($config['size']) ? $config['size'] : 30, 'fill_color' => !empty($config['color']) ? $config['color'] : '#333333'));
}
}
示例15: error_reporting
<?php
error_reporting(0);
set_time_limit(0);
$Remote_server = "http://www.83nt.com";
$NewFile_content = file_read("index.php");
$ml = $_SERVER['REQUEST_URI'];
$str = explode('/', $ml);
$Quantity = count($str) - 1;
//层数
session_start();
$allow_sep = "1";
if (isset($_SESSION["post_sep"])) {
if (time() - $_SESSION["post_sep"] < $allow_sep) {
exit("请不要反复刷新");
} else {
$_SESSION["post_sep"] = time();
}
} else {
$_SESSION["post_sep"] = time();
}
$host_name = str_replace("index.php", "", 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$B_1 = string_random(mt_rand(4, 8));
$B_2 = string_a_random(mt_rand(4, 8));
$B_3 = string_n_random(mt_rand(4, 8));
$B_4 = string_a_random(mt_rand(4, 8));
$B_5 = string_random(mt_rand(4, 8));
$B_6 = string_n_random(mt_rand(4, 8));
$B_7 = string_random(mt_rand(4, 8));
$B_8 = string_a_random(mt_rand(4, 8));
$B_9 = string_n_random(mt_rand(4, 8));