php 基础函数

yipeiwu_com7年前PHP代码库

话不多说,如下所示:

<?php
//生成随机数 和 时间函数
//echo rand();
//echo "<br>";
//echo rand(0,10);
//echo time();//时间戳
//2017-02-10 08:46:12
date_default_timezone_set("Asia/Shanghai");
//echo date("Y-m-d h:i:s");//默认转换当前时间
//echo date("Y-m-d h:i:s",'1386688343');
//echo strtotime("2013-12-10 11:12:23");
//字符串的处理
$str = 'Hello World!!!';
//echo strlen($str);
//$str1='Abc';
//$str2='abc';
//echo strcmp($str1,$str2);
//echo strcasecmp($str1,$str2);
echo strtoupper($str2);
echo strtolower($str1);
//$str = "a|B|c|d";
//$str1 = explode("|",$str);
//echo implode("&",$str1);
//echo substr($str,1,3);
//echo str_replace("|","&",$str);
//echo substr_replace($str,"%",1,1);
$str = "hello3 world4 ashdf223sdfa2323sd45454";
//preg_match("/\d/",$str,$str2);
//preg_match_all("/\d/",$str,$str3);
//var_dump($str3);
//$str4 = preg_replace("/\d/", "数字", $str);
//var_dump($str4);
$str5 = preg_split("/\d/",$str);
var_dump($str5);

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持【宜配屋www.yipeiwu.com】!

相关文章

PHP中创建和验证哈希的简单方法实探

 PHP 5.5.0 带来了一份完整的全新特性与函数的列表。全新API之一就是Password Hashing API.它包含4个函数:password_get_info(),...

高质量PHP代码的50个实用技巧必备(上)

50个高质量PHP代码的实用技巧,希望大家喜欢。 1.不要使用相对路径 常常会看到: require_once('../../lib/some_class.php'); 该...

在PHP中使用redis

在Mac OS上安装redis首先是安装,它会默认安装到/usr/local/bin下复制代码 代码如下:cd /tmpwget http://redis.googlecode.com/...

PHP运行出现Notice : Use of undefined constant 的完美解决方案分享

Notice: Use of undefined constant ALL_PS - assumed 'ALL_PS' in E:\Server\vhosts\www.lvtao.net...

PHP+JS实现大规模数据提交的方法

本文实例讲述了PHP+JS实现大规模数据提交的方法。分享给大家供大家参考。具体实现方法如下: <?php session_start(); ?> <...