Home > Backend Development > PHP Tutorial > Example of php file_get_content compatibility detection

Example of php file_get_content compatibility detection

WBOY
Release: 2016-07-25 08:59:48
Original
845 people have browsed it
Let me introduce to you an example of using file_get_content to detect compatibility in PHP. Friends in need can take a look.

The code is as follows:

<?php
/**
 * PHP 兼容性函数
 * http://bbs.it-home.org
 */
if(!function_exists('file_put_contents')) {
 if(!defined('FILE_APPEND')) define('FILE_APPEND', 8);
   function file_put_contents($filename, $data, $flag = 0) {
   $return = false;
   if($fp = @fopen($filename, $flag != FILE_APPEND ? 'w' : 'a')) {
      if($flag == LOCK_EX) @flock($fp, LOCK_EX);
         $return = fwrite($fp, is_array($data) ? implode('', $data) : $data);
         fclose($fp);
  }
  return $return;
 }
}
?>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template