function data_uri($file, $mime) { $contents=file_get_contents($file); $base64=base64_encode($contents); echo "data:$mime;base64,$base64"; }2.合并JavaScript和CSS文件
function combine_my_files($array_files, $destination_dir, $dest_file_name){ if(!is_file($destination_dir . $dest_file_name)){ //continue only if file doesn't exist $content = ""; foreach ($array_files as $file){ //loop through array list $content .= file_get_contents($file); //read each file } //You can use some sort of minifier here //minify_my_js($content); $new_file = fopen($destination_dir . $dest_file_name, "w" ); //open file for writing fwrite($new_file , $content); //write to destination fclose($new_file); return ' '; //output combined file }else{ //use stored file return ' '; //output combine file } }并且,用法是這樣的:
$files = array( 'http://example/files/sample_js_file_1.js', 'http://example/files/sample_js_file_2.js', 'http://example/files/beautyquote_functions.js', 'http://example/files/crop.js', 'http://example/files/jquery.autosize.min.js', ); echo combine_my_files($files, 'minified_files/', md5("my_mini_file").".js");3.查看你的電子郵件是否已讀
error_reporting(0); Header("Content-Type: image/jpeg"); //Get IP if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } //Time $actual_time = time(); $actual_day = date('Y.m.d', $actual_time); $actual_day_chart = date('d/m/y', $actual_time); $actual_hour = date('H:i:s', $actual_time); //GET Browser $browser = $_SERVER['HTTP_USER_AGENT']; //LOG $myFile = "log.txt"; $fh = fopen($myFile, 'a+'); $stringData = $actual_day . ' ' . $actual_hour . ' ' . $ip . ' ' . $browser . ' ' . "\r\n"; fwrite($fh, $stringData); fclose($fh); //Generate Image (Es. dimesion is 1x1) $newimage = ImageCreate(1,1); $grigio = ImageColorAllocate($newimage,255,255,255); ImageJPEG($newimage); ImageDestroy($newimage); ?>
4.從網頁提取關鍵詞$meta = get_meta_tags('http://www.emoticode.net/'); $keywords = $meta['keywords']; // Split keywords $keywords = explode(',', $keywords ); // Trim them $keywords = array_map( 'trim', $keywords ); // Remove empty values $keywords = array_filter
文章轉載請保留網址:http://cctvsc.cn/news/solutions/1647.html