本文介绍了如何运行这个PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我从互联网上获得了这个PHP代码。我将其保存在txt文件中,并将名称保存到abc.php。但它没有运行。在chrome上打开文件时。它只显示代码 <?php //检查下载令牌 if(empty($ _ GET) ['mime'])或空($ _ GET ['token'])) { exit('无效下载令牌8 {'); } //设置操作参数 $ mime = filter_var($ _ GET ['mime']); $ ext = str_replace(array('/','x - '),'',strstr($ mime,'/')); $ url = base64_decode(filter_var($ _ GET ['token'])); $ name = urldecode($ _ GET ['title'])。 '。'。$ ext; //获取并提供 if($ url) { //生成服务器头 if(strpos($ _ SERVER ['HTTP_USER_AGENT'],' MSIE')!== FALSE) {/ * header('Content-Type:''。$ mime。''); header('Content-Disposition:attachment; filename ='。$ name。''); header('Expires:0'); header('Cache-Control:must-revalidate,post-check = 0,pre-check = 0'); header(Content-Transfer-Encoding:binary); header('Pragma:public'); * /} else {/ * header('Content-Type:'。$ mime。''); header('Content-Disposition:attachment; filename ='。$ name。''); header(Content-Transfer-Encoding:binary); header('Expires:0'); header('Pragma:no-cache'); * /} $ download_video_file = file_put_contents($ file_path,fopen($ url,'r')); 退出; } //未找到退出('找不到文件8 {'); ?> 解决方案 _GET ['token'])) { exit('无效下载令牌8 {'); } //设置操作参数 i got this php code below from internet.I saved it in txt file and saved name to abc.php. but it is not running. when opening the file on chrome. it just showing the code<?php// Check download tokenif (empty($_GET['mime']) OR empty($_GET['token'])){exit('Invalid download token 8{');}// Set operation params$mime = filter_var($_GET['mime']);$ext = str_replace(array('/', 'x-'), '', strstr($mime, '/'));$url = base64_decode(filter_var($_GET['token']));$name = urldecode($_GET['title']). '.' .$ext; // Fetch and serveif ($url){// Generate the server headersif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE){/* header('Content-Type: "' . $mime . '"'); header('Content-Disposition: attachment; filename="' . $name . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-Transfer-Encoding: binary"); header('Pragma: public');*/}else{/* header('Content-Type: "' . $mime . '"'); header('Content-Disposition: attachment; filename="' . $name . '"'); header("Content-Transfer-Encoding: binary"); header('Expires: 0'); header('Pragma: no-cache');*/}$download_video_file = file_put_contents($file_path, fopen($url, 'r'));exit;}// Not foundexit('File not found 8{');?> 解决方案 这篇关于如何运行这个PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 23:38