"Fatal error: Call to undefined function: file_put_contents()"
打开页面时提示这个错误:
Fatal error: Call to undefined function: file_put_contents()
意思是请求未定义的函数,出现这个提示通常有两种情况:
1.当前php版本不支持此函数
2.请求的函数是用户自定义编写,但是找不到这个函数所在的文件
file_put_contents函数的php支持版本是从5.0开始,见:http://cn2.php.net/manual/zh/function.file-put-contents.php
查看了一下机器当前php版本是4.4.2,那么就出现第一种情况php版本不支持了,不过就算版本不支持还是可以做下改动让它支持的:
define('FILE_APPEND', 1);
if (!function_exists("file_put_contents")) {
function file_put_contents($n, $d, $flag = false) {
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
$f = @fopen($n, $mode);
if ($f === false) {
return 0;
} else {
if (is_array($d)) $d = implode($d);
$bytes_written = fwrite($f, $d);
fclose($f);
return $bytes_written;
}
}
}
将这段代码添加到调用file_put_contents函数之前的代码文件中就可以解决问题,重新打开页面就不会出现这个提示。
"Fatal error: Call to undefined function: file_put_contents()"的更多相关文章
- fatal error: Call to undefined function mysqli_connect()
在搭建PHP5.6+APACHE2.4+MYSQL5的平台时,测试是否成功连接mysql, 测试程序index.php <?php phpinfo() ?> 没有出现mysql的信息 所以 ...
- Fatal error: Call to undefined function imagettftext()解决办法
Fatal error: Call to undefined function imagettftext()解决办法 我的问题是php编译安装时指定了gd的目录,其实不用指定.就可以了 博客分类: ...
- php提示Fatal error: Call to undefined function imagecreate()
在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会 / ...
- Fatal error: Call to undefined function mysql_connect()
我在进行PHP环境搭建:Windows 7下安装配置PHP+Mysql+apache环境时,之前都没有什么问题,只是在验证PHP是否能连接Mysql时出现如下错误:Fatal error: Call ...
- Fatal error: Call to undefined function json_decode()解决办法
最近搭建测试服务器,访问网站查看报错日志出现如下错误: Fatal error: Call to undefined function json_decode() 出现该问题原因是安装PHP时没有安装 ...
- Fatal error: Call to undefined function mb_strlen()
php配置的时候出现:Fatal error: Call to undefined function mb_strlen() 表示php不能加载mbstring模块,在php 的配置文件php.in ...
- PHP Fatal error: Call to undefined function mysql_connect() 错误解释
我使用的是5.6.11版本的php 刚开始以为编译参数加了--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd,就可以不能安装mysql了. 但是使用了mysq ...
- 又一个错误" Fatal error: Call to undefined function myabp_print_screenshot_all() "
xxx ( ! ) Fatal error: Call to undefined function myabp_print_screenshot_all() in D:\wamp\www\wp-con ...
- PHP Fatal error: Call to undefined function think\finfo_open()
PHP Fatal error: Call to undefined function think\finfo_open() php.ini extension=php_fileinfo. ...
随机推荐
- centos环境搭建
1.php -v 与phpinfo(); 不符,查看centos是否有自带的php:更改centos环境变量 /etc/profile,source /etc/profile生效: 2.pecl ...
- windows7下Wamp安装php扩展imagick(转)
ImageMagick是一套功能强大.稳定而且免费的工具集和开发包,可以用来读.写和处理超过185种基本格式的图片文件,包括流行的TIFF, JPEG, GIF, PNG, PDF以及PhotoCD等 ...
- leetcode--Different Ways to Add Parentheses
题目链接:https://leetcode.com/submissions/detail/86532557/ 算法类型:分治法 题目分析:计算表达式的所有结果可能性 代码实现: class Solut ...
- codeforces 459E
codeforces 459E E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabyte ...
- marquee上下左右循环无缝滚动代码
一.横向滚动<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN "><HTML>< ...
- python画决策树
1.安装graphviz.下载地址在:http://www.graphviz.org/.如果你是linux,可以用apt-get或者yum的方法安装.如果是windows,就在官网下载msi文件安装. ...
- Linux下配置python环境
- struts2使用annotation注意事项
struts2使用annotation注意事项 1.包名只能以.action .actions .struts .struts2结尾.如:com.cnbolgs.web.actions 2.类名只 ...
- CSS属性小结之--半透明处理
项目中经常有遇到需求半透明的情况,如图片.文字.容器.背景等等,每次都要去翻以前的项目,不甚其烦.现在一次性做个小结,方便自己查阅,也同时分享给大家: 一. 元素容器透明 .div{ opacity: ...
- HDU4411 最小费用流
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4411 floyd处理出最短路 每个点拆为i.i+n,i到i+n连一条容量为1,费用为负无穷的边,代表这个城 ...