博客
关于我
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

你可能感兴趣的文章
NoSQL&MongoDB
查看>>
NoSQL介绍
查看>>
NoSQL数据库概述
查看>>
Notadd —— 基于 nest.js 的微服务开发框架
查看>>
NOTE:rfc5766-turn-server
查看>>
Notepad ++ 安装与配置教程(非常详细)从零基础入门到精通,看完这一篇就够了
查看>>
Notepad++在线和离线安装JSON格式化插件
查看>>
notepad++最详情汇总
查看>>
notepad++正则表达式替换字符串详解
查看>>
notepad如何自动对齐_notepad++怎么自动排版
查看>>
Notes on Paul Irish's "Things I learned from the jQuery source" casts
查看>>
Notification 使用详解(很全
查看>>
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
查看>>
NotImplementedError: Could not run torchvision::nms
查看>>
nova基于ubs机制扩展scheduler-filter
查看>>
Now trying to drop the old temporary tablespace, the session hangs.
查看>>
nowcoder—Beauty of Trees
查看>>
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
np.power的使用
查看>>
NPM 2FA双重认证的设置方法
查看>>