onethink-(03)-php内置函数
来源:互联网 发布:apache安装无法访问 编辑:程序博客网 时间:2024/06/15 08:29
php内置函数有1300多个?但是平时接触到的也就那么10几个
array_pop() 函数删除数组中的最后一个元素,并返回最后的那个元素。
例子<?php$a=array("Dog","Cat","Horse");array_pop($a);print_r($a);?>输出:Array ( [0] => Dog [1] => Cat )
parse_str() 函数把查询字符串解析到变量中。
例子 1<?phpparse_str("id=23&name=John%20Adams");echo $id."<br />";echo $name;?>输出:23John Adams例子 2<?phpparse_str("id=23&name=John%20Adams",$myArray);print_r($myArray);?>输出:Array([id] => 23[name] => John Adams)
call_user_func_array
call_user_func_array(PHP 4 >= 4.0.4, PHP 5)call_user_func_array — Call a callback with an array of parameters说明mixed call_user_func_array ( callable $callback , array $param_arr )Calls the callback given by the first parameter with the parameters in param_arr.参数callback The callable to be called.param_arr The parameters to be passed to the callback, as an indexed array.返回值Returns the return value of the callback, or FALSE on error.
php函数serialize()与unserialize()
php函数serialize()与unserialize()serialize()和unserialize()在php手册上的解释是:serialize — Generates a storable representation of a valueserialize — 产生一个可存储的值的表示unserialize — Creates a PHP value from a stored representationunserialize — 从已存储的表示中创建 PHP 的值<?php//声明一个类class dog { var $name; var $age; var $owner; function dog($in_name="unnamed",$in_age="0",$in_owner="unknown") { $this->name = $in_name; $this->age = $in_age; $this->owner = $in_owner; } function getage() { return ($this->age * 365); } function getowner() { return ($this->owner); } function getname() { return ($this->name); }}//实例化这个类$ourfirstdog = new dog("Rover",12,"Lisa and Graham");//用serialize函数将这个实例转化为一个序列化的字符串$dogdisc = serialize($ourfirstdog);print $dogdisc; //$ourfirstdog 已经序列化为字符串 O:3:"dog":3:{s:4:"name";s:5:"Rover";s:3:"age";i:12;s:5:"owner";s:15:"Lisa and Graham";}print '<BR>';/*----------------------------------------------------------------------------------------- 在这里你可以将字符串 $dogdisc 存储到任何地方如 session,cookie,数据库,php文件-----------------------------------------------------------------------------------------*///我们在此注销这个类unset($ourfirstdog);/* 还原操作 *//*----------------------------------------------------------------------------------------- 在这里将字符串 $dogdisc 从你存储的地方读出来如 session,cookie,数据库,php文件-----------------------------------------------------------------------------------------*///我们在这里用 unserialize() 还原已经序列化的对象$pet = unserialize($dogdisc); //此时的 $pet 已经是前面的 $ourfirstdog 对象了//获得年龄和名字属性$old = $pet->getage();$name = $pet->getname();//这个类此时无需实例化可以继续使用,而且属性和值都是保持在序列化之前的状态print "Our first dog is called $name and is $old days old<br>";print '<BR>';?>
0 0
- onethink-(03)-php内置函数
- PHP数组内置函数
- php内置函数
- PHP基本内置函数
- php内置函数number_format
- PHP内置函数--CURL
- php内置函数集锦
- PHP内置字符串函数实现
- PHP内置字符串函数实现
- php常用的内置函数
- php 内置excel操作函数
- php 内置数组排序函数
- PHP的内置函数call_user_func()
- PHP内部(内置)函数
- smarty 调用php内置函数
- smarty 调用php内置函数
- PHP 数组排序内置函数
- php 常用的内置函数
- 智能手机的功能越来越复杂,可惜用户不买账
- JBPM (三) 服务和实例介绍
- C++常见的编译错误中英对应翻译
- [Leetcode] Unique Binary Search Trees II (Java)
- 阿牛的EOF牛肉串(参考别人的思路写的代码)
- onethink-(03)-php内置函数
- linux 安装笔记 三、JAVA配置
- 老人地铁上拍醒熟睡女孩:快起来我要坐
- 黑马程序员 <银行业务调度系统>
- 手机离线地图进行GPS定位
- JavaWeb编码过滤器
- jsp实践
- FTP基础知识
- crontab不能成功执行shell脚本的可能原因