php var_dump简单测试
void var_dump ( mixed expression [, mixed expression [, ...]])
此函数显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开值,通过缩进显示其结构。
*/
function a_test($str) //自定义函数
{
echo "nhi: $str"; //输出参数
var_dump(debug_backtrace()); //输出backtrace
}
a_test('friend'); //调用用户自定义函数
//再来看一个var_dump遍历对象实例吧
class foo {
private $a;
public $b = 1;
public $c='111cn.net';
private $d;
static $e;
public function test() {
var_dump(get_object_vars($this));
}
}
$test = new foo;
var_dump(get_object_vars($test));
$test->test();
//注意:为了防止程序直接将结果输出到浏览器,可以使用输出控制函数来捕获此函数的输出,并把它们保存到一个例如 string 类型的变量中。
hexdec() 函数把十六进制转换为十进制。
语法
hexdec(hex_string)
echo hexdec('77'); //输出119
echo "<br>";
echo hexdec(dechex(43)); //输出43
echo "<br>";
echo hexdec('3a'); //输出58
dechex() 函数把十进制转换为十六进制。
语法
dechex(dec_number)
include 'include.php教程'; //引用include.php文件
echo a();
//结果 bb
?>
include.php文件如下
<?php
//建立include.php以供其他文件调用
function a() //定义函数a
{
b(); //在函数a中调用函数b
}
function b() //定义函数b
{
c(); //在函数b中调用函数c
}
function c() //定义函数c
{
echo('bb'); //输出一个php backtrace
}
a(); //使用函数a
?>
其它提示:
在使用require()语句调用文件时,如果没有找到文件,require()语句会输出错误信息,并且立即终止脚本的处理.而include()语句在没有找到文件时则会输出警告,不会终止脚本的处理
定义和用法
error_reporting() 设置 php 的报错级别并返回当前级别。
语法
error_reporting(report_level)如果参数 level 未指定,当前报错级别将被返回。下面几项是 level 可能的值
*/
//关闭所有的错误报告
error_reporting(0);
//只报告运行错误
error_reporting(e_error|e_warning|e_parse);
//报告e_notice
error_reporting(e_error|e_warning|e_parse|e_notice);
//报告所有的运行错误,除了e_notice
//这是php.ini的默认值
error_reporting(e_all ^ e_notice);
//报告所有的php错误
error_reporting(e_all);
//和error_reporting(e_all)有一样的功效,该设置也会报告所有php错误
ini_set('error_reporting', e_all);
/*
值 常量 描述
1 e_error fatal run-time errors. errors that can not be recovered from. execution of the script is halted
2 e_warning non-fatal run-time errors. execution of the script is not halted
4 e_parse compile-time parse errors. parse errors should only be generated by the parser
8 e_notice run-time notices. the script found something that might be an error, but could also happen when running a script normally
16 e_core_error fatal errors at php startup. this is like an e_error in the php core
32 e_core_warning non-fatal errors at php startup. this is like an e_warning in the php core
64 e_compile_error fatal compile-time errors. this is like an e_error generated by the zend scripting engine
128 e_compile_warning non-fatal compile-time errors. this is like an e_warning generated by the zend scripting engine
256 e_user_error fatal user-generated error. this is like an e_error set by the programmer using the php function trigger_error()
512 e_user_warning non-fatal user-generated warning. this is like an e_warning set by the programmer using the php function trigger_error()
1024 e_user_notice user-generated notice. this is like an e_notice set by the programmer using the php function trigger_error()
2048 e_strict run-time notices. php suggest changes to your code to help interoperability and compatibility of the code
4096 e_recoverable_error catchable fatal error. this is like an e_error but can be caught by a user defined handle (see also set_error_handler())
8191 e_all all errors and warnings, except level e_strict (e_strict will be part of e_all as of php 6.0)
*/
function unserialize_handler($errno,$errstr) //自定义函数
{
echo "invalid serialized value.n"; //输出指定内容
}
$serialized='foo'; //定义字符串
set_error_handler('unserialize_handler'); //设置用户自定义错误信息函数
$original=unserialize($serialized); //从已存储的表示中创建php的值
restore_error_handler(); //恢复错误信息指针
<?php教程
$action = trim($_get['action']);
if($action == "sub")
{
$str = $_post['dir'];
//if(!preg_match("/^[".chr(0xa1)."-".chr(0xff)."a-za-z0-9_]+$/",$str)) //gb2312汉字字母数字下划线正则表达式
if(!preg_match("/^[x{4e00}-x{9fa5}a-za-z0-9_]+$/u",$str)) //utf-8汉字字母数字下划线正则表达式
{
echo "<font color=red>您输入的[".$str."]含有违法字符</font>";
}
else
{
echo "<font color=green>您输入的[".$str."]完全合法,通过!</font>";
}
}
?>
相关文章
- 最基础的对数据的增加删除修改操作实例,菜鸟们收了吧...2013-09-26
- 这篇文章主要介绍了解决@SpringBootTest 单元测试遇到的坑,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-10-14
- mysqldump命令的用法1、导出所有库系统命令行mysqldump -uusername -ppassword --all-databases > all.sql 2、导入所有库mysql命令行mysql>source all.sql; 3、导出某些库系统命令行mysqldump -uusername -ppassword...2015-10-21
- DVWA (Dam Vulnerable Web Application)DVWA是用PHP+Mysql编写的一套用于常规WEB漏洞教学和检测的WEB脆弱性测试程序。包含了SQL注入、XSS、盲注等常见的一些安全漏洞...2016-11-25
- 宿主机使用网线的时候,客户机在Bridged Adapter模式下,使用Atheros AR8131 PCI-E Gigabit Ethernet Controller上网没问题。 宿主机使用无线的时候,客户机在Bridged Adapter模式下,使用可选项里唯一一个WIFI选项,Microsoft Virtual Wifi Miniport Adapter也无法上网,故弃之。...2013-09-19
- mail()函数的作用:连接到邮件服务器,利用smtp协议,与该服务器交互并投邮件。注意:1、mail函数不支持esmtp协议,---即,只能直投,不能登陆2、由上条,我们只能直投至最终的收件服务器地址.而该地址,又是在PHP.ini中指定的,所...2015-10-30
- mail()函数的作用:连接到邮件服务器,利用smtp协议,与该服务器交互并投邮件。注意:1、mail函数不支持esmtp协议,---即,只能直投,不能登陆2、由上条,我们只能直投至最终的收件服务器地址.而该地址,又是在PHP.ini中指定的,所...2015-10-30
- 在MySQL中,InnoDB引擎类型的表支持了外键约束。 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持); 2.外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时...2015-11-24
- 这篇文章主要介绍了js简单网速测试方法,以完整实例形式分析了JavaScript基于网页图片下载进行测试网速的实现技巧,需要的朋友可以参考下...2015-12-17
- php测试性能代码 function microtime_float () { list ($usec, $sec) = explode(" ", microtime()); return ((float) $usec + (float) $sec); } functio...2016-11-25
- C# 实现简单打印的实例代码,需要的朋友可以参考一下...2020-06-25
- 下面我们一起来看看一篇关于phpmyadmin写入一句话木马的测试教程,希望此教程能够对各位有帮助。 方法一,一句话木马偶尔拿到一个config中,发现是root,且还有phpmyadmi...2016-11-25
- 这篇文章主要为大家介绍了python自动化测试selenium执行js脚本的实现示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步...2021-11-13
- 这篇文章主要介绍了Redis 执行性能测试的方法,文中讲解非常细致,帮助大家更好的理解和学习redis,感兴趣的朋友可以了解下...2021-01-15
- 这篇文章主要介绍了JavaWeb实战之编写单元测试类测试数据库操作,文中有非常详细的代码示例,对正在学习javaweb的小伙伴们有很大的帮助,需要的朋友可以参考下...2021-04-22
- 这篇文章主要介绍了Springboot 使用具体化类和配置来缩短单元测试时间,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-11-05
- 这篇文章主要给大家介绍了关于oracle索引测试的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-17
- 本文主要接好了python接口自动化的接口概念、接口用例设计及登录,跟随本文章来进行一个接口用例设计及登录接口测试实战,有需要的朋友可以参考下...2021-08-25
- [ajax介绍] ajax是使用客户端脚本与web服务器交换数据的web应用开发方法。web页面不用打断交互流程进行重新加裁,就可以动态地更新。使用ajax,用户可以创建接近本地...2016-11-25
- 下面小编就为大家分享一篇.Net Core内存回收模式及性能测试对比分析,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-09-22