标签:err 如何 order 输出 当前日期 utf-8 print 同名 report
<?php $sub = "www.baidu.com"; $ptn = '/\w*\.\w*\.\w*/'; // 正則表達式,元数据,返回的数据 preg_match($ptn, $sub,$mats); echo "<pre>"; print_r($mats); echo "</pre>"; ?>
<?php $str = "my ip is 192.168.10.1sdjlfajdf192.178.39.4la"; $ptn = '/\d+\.\d+\.\d+\.\d+/'; preg_match_all($ptn, $str,$mats); echo "<pre>"; print_r($mats); echo "</pre>"; ?>
<?php $str = "Linux and php are lamp or linux is very much"; $ptn = '/linux/i'; preg_match_all($ptn, $str,$mats); echo "<pre>"; print_r($mats); echo "</pre>"; ?>
<?php $str = "Linux and php are lamp or \nlinux is very much"; $ptn = '/^linux/im'; preg_match_all($ptn, $str,$mats); echo "<pre>"; print_r($mats); echo "</pre>"; ?
>
<?php $str = "Linux and php are lamp or \nlinux is very much"; $ptn = '/.*/s'; preg_match_all($ptn, $str,$mats); echo "<pre>"; print_r($mats); echo "</pre>"; ?>
<?php $str = "123 php"; $ptn = '/\d+\s(\w+)/e'; $rep = 'strtoupper($1)'; // preg_match_all($ptn, $str,$mats); $str2 = preg_replace($ptn, $rep, $str); echo "<pre>"; print_r($str2); echo "</pre>"; ?>
<?php $str = "123 php"; $ptn = '/(\d+)(\s)(\w+)/'; $rep = '$3$2$1'; // preg_match_all($ptn, $str,$mats); $str2 = preg_replace($ptn, $rep, $str); echo "<pre>"; print_r($str2); echo "</pre>"; ?>
<?php //比方代表文章 $arr = array( "php html", " linux redhat rhce", "junzaivip test php", ); //须要搜索的内容 $ptn = '/junzaivip/'; //返回搜索到的内容 $arr2 = preg_grep($ptn, $arr); echo "<pre>"; print_r($arr2); echo "</pre>"; ?>
<?php echo max(3,45,6,7); echo "<br>"; echo max(array(4,6,8,9)); ?
>
<?php echo time(); echo "<hr>"; echo date("Y-m-d H:i-s w t",0); ?>
<?php echo strtotime("2014-12-12"); ?>
<?php echo date("Y-m-d H:i:s",time()+8*3600); ?>
<?php //设置中国的时区为默认时区 date_default_timezone_set("PRC"); echo date("Y-m-d H:i:s",time()); ?>
<?php //设置中国的时区为默认时区 date_default_timezone_set("PRC"); $y = "1900/1/1"; $time = strtotime($y); echo date("L",$time); ?>
<?php $stime = microtime(1);//注意这个位置必须用true,否者无法參与计算 sleep(1); $etime = microtime(1); echo $etime - $stime; ?>
<?php //改动字符编码 //header("content-type:text/html;charset=utf-8"); date_default_timezone_set("PRC"); //获取当前年 $year = $_GET['y']?$_GET['y']:date('Y'); //获取当前月 $month = $_GET['m']?
$_GET['m']:date('m'); //获取获取当前月有多少天 $days = date('t',strtotime("{$year}-{$month}-1"));//里面必须用双引號 //当前一号是周几 $weeks = date('w',strtotime("{$year}-{$month}-1")); //全部有内容居中 echo "<center>"; //输出表头 echo "<h2>{$year}年{$month}月</h2>"; //输出日期表格 echo "<table width='700px' border='1px'>"; //输出第一行 echo "<tr>"; //表头单元格由th来创建 echo "<th>日</th>"; echo "<th>一</th>"; echo "<th>二</th>"; echo "<th>三</th>"; echo "<th>四</th>"; echo "<th>五</th>"; echo "<th>六</th>"; echo "</tr>"; //開始铺表格 for($i = 1 - $weeks;$i <= $days;){ echo "<tr>"; for ($j=0; $j < 7; $j++) { if ($i > $days || $i < 1) { echo "<td> </td>"; } else{ echo "<td>{$i}</td>"; } $i++; } echo "</tr>"; } echo "</table>"; //实现一下上一年和上一月 if($month == 1){ $prevyear = $year - 1; $prevmonth = 12; } else{ $prevyear = $year; $prevmonth = $month -1; } if($month == 12){ $nextyear = $year + 1; $nextmonth = 1; } else{ $nextyear = $year; $nextmonth = $month + 1; } //输出上一月和下一月的button echo "<h2><a href = 'index.php?y={$prevyear}&m={$prevmonth}'>上一月</a>|<a href='index.php?
y={$nextyear}&m={$nextmonth}'>下一月</a></h2>"; echo "</center>"; ?
>
标签:err 如何 order 输出 当前日期 utf-8 print 同名 report
原文地址:http://www.cnblogs.com/gavanwanggw/p/7064807.html