Home  >  Article  >  Backend Development  >  Example of php file_get_content compatibility detection

Example of php file_get_content compatibility detection

WBOY
WBOYOriginal
2016-07-25 08:59:48797browse
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;
 }
}
?>


Statement:
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