返回文件内容相关函......登陆

文件内容相关函数案例

幽悠的叶子2019-02-18 11:43:35220

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<?php

echo strip_tags(file_get_contents('text/txt.txt'));   //获取去除HTML标记的文件内容

//-------------------------------------------------------------------------------------

echo file_get_contents('http://www.baidu.com');       //获取远程文件内容

//-------------------------------------------------------------------------------------

header('content-type:image/png');

echo file_get_contents('http://www.baidu.com/img/bd_logo.png');  //获取图片  需声明头部

//-------------------------------------------------------------------------------------

//数组

$data = [

    'name'=>'波加曼',

    'kill'=>'泡沫光线'

];

 

//序列化

var_dump(file_put_contents('text/txt3.txt', serialize($data)));

var_dump(unserialize(file_get_contents('text/txt3.txt')));

//------------------------------------------------------------------------------------

//json

var_dump(file_put_contents('text/txt3.txt', json_encode($data)));

var_dump(json_decode(file_get_contents('text/txt3.txt')));


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送