博客
关于我
PHP函数方法
阅读量:793 次
发布时间:2023-03-01

本文共 1232 字,大约阅读时间需要 4 分钟。

补充一个P可以HP的特点函数:动态调用

function t(){

echo "welcome";

}

function t2(){

echo "beatch";

}

$s = 'wel';

$s();//输出了welcome;可以用变量的值调用函数

不加global函数里面的$a和外部的$a无关 加了global就是可以调用全局变量 不推荐使用

function t(){

global $a ;

}

$a = 22;

echo '$a';

time():从1970,0101开始过去多少秒

microtime();这一秒过去多少毫秒 有两行第一行是这一秒过去多少毫秒 第二行是从19700101开始过去多少秒

microtime(true);从1970年0101开始过去多少秒 点 多少毫秒

 

data();

$time=time()

date('Y-m-d 星期N','$time');返回的是现在时间的几几年几月几日星期几 数字格式的可看手册方法 $time可以去掉

gmdate();

gmdate()返回的是时区问题 格林威特时区???

mktime(时分秒月日时);//按照给定的时间计算返回过去多少秒了

strtotime();给字符串解析时间 比如 now指现在就解析过去多少秒了 now +1 day

checkdate(日月年);检测时间是否合法

 

strlen()获取字符串长度\

要解析中文长度:$str='中国'; echo strlen($str,'utf-8');中文长度为2

 

$strpos()是否含有某个字符

$a='abcde'; $b='b'; if(strpos($a,$b)!==false){

echo '含有',$b;

}else

{

echo '不含有',$b;

}

替换字符串:str_replace

$str='hi shit';

echo str_replace('shit','s**t',$str);

 

多个替换:strtr

$str='男人','女人','男孩','女孩';

strtr($str,array('男'=>'女','女'=>'男'));

截取子字符串:substr

$str='abcdefghrjklmn';

substr($str,0,3);//截取了abcb如3 -3从第三个数到倒数第四个开始截取内容

拆分字符串:explode

$str='tech','linux','mysql';

$arr=explode(',',$str);被逗号隔成三个字符串 输出是0角标对应的是什么内容

print_r($arr);

 echo implode($arr,',');将数组对于的字符串 又转换成字符串

 

转载于:https://www.cnblogs.com/hello-web/p/7624939.html

你可能感兴趣的文章
Nginx学习总结(14)——Nginx配置参数详细说明与整理
查看>>
Nginx安装与常见命令
查看>>
Nginx安装及配置详解
查看>>
Nginx实战经验分享:从小白到专家的成长历程!
查看>>
Nginx实现反向代理负载均衡
查看>>
nginx实现负载均衡
查看>>
nginx开机启动脚本
查看>>
nginx异常:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf
查看>>
nginx总结及使用Docker创建nginx教程
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:128
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in usrlocalnginxconfnginx.conf128
查看>>
nginx日志分割并定期删除
查看>>
Nginx日志分析系统---ElasticStack(ELK)工作笔记001
查看>>
Nginx映射本地json文件,配置解决浏览器跨域问题,提供前端get请求模拟数据
查看>>
nginx最最最详细教程来了
查看>>
Nginx服务器---正向代理
查看>>
Nginx服务器上安装SSL证书
查看>>
Nginx服务器的安装
查看>>
Nginx模块 ngx_http_limit_conn_module 限制连接数
查看>>
nginx添加模块与https支持
查看>>