https://www.myziyuan.com/
- 111
- $_env 是环境变量,通过环境方式传递给当前脚本的变量的数组。$_ENV['defaultapp'] = array('portal.php' => 'portal', 'forum.php' => 'forum', 'group.php' => 'group', 'home.php' => 'home');是赋值 , 你可以用 var_dump($_env['defaultapp']) 看赋值结果。--------------------------------------------------------------------$_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);环境变量 用.分隔 主域名(你可以 echo $_server['HTTP_HOST']里面有什么)----------------------------------------------------------------$url = $domainroot.'forum.php?mod=group&fid='.$domain['id'].'&page=1';构造一个URL 直白点 结果就是: www.some.com/forum.php?mod=1&fid=1&page=1----------------------------------------$url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : 'http://'.$_ENV['domain']['app']['default'];结构简化 $url = $a ? (!$b? $c : $d) :$e; 2个3元运算嵌套, 至于看起来复杂的变量都是多维数组的值
- 2021-02-16 06:30:01
- 葬爱落雨
- <?phpfunction modelup($len){$str="";for($i=0;$i<$len;$i++){ for($n=$len;$n>$i;$n--){ $str.=" "; } for($j=0;$j<$i+1;$j++){ $str.=" * "; } $str.="<br>";}return $str;}function modeldown($len){$str="";for($i=0;$i<$len;$i++){ for($n=0;$n<$i+2;$n++){ $str.=" "; } for($j=5;$j>$i;$j--){ $str.=" * "; } $str.="<br>";}return $str;}function model($len){return modelup($len).modeldown($len);}echo model(6);?>输出结果* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- 2021-02-11 14:10:52
- 苹果cms
- php源代码,<?php functionDateAdd($date,$int,$unit="d"){//时间的增加(还可以改进成时分秒都可以增加,有时间再补上) $dateArr=explode("-",$date); $value[$unit]=$int; //OSPHP.COM.Cn开源returndate("Y-m-d",mktime(0,0,0,$dateArr[1]+$value['m'],$dateArr[2]+$value['d'],$dateArr[0]+$value['y'])); //开源OSPhP.COM.CN } functionGetWeekDay($date){//计算出给出的日期是星期几 $dateArr=explode("-",$date); returndate("w",mktime(0,0,0,$dateArr[1],$dateArr[2],$dateArr[0])); //OsPHP.COM.CN} ?> <? functioncheck_date($date){//检查日期是否合法日期 $dateArr=explode("-",$date); if(is_numeric($dateArr[0])&&is_numeric($dateArr[1])&&is_numeric($dateArr[2])){ //开源代码OSPHP.COM.Cn returncheckdate($dateArr[1],$dateArr[2],$dateArr[0]); } returnfalse; } functioncheck_time($time){//检查时间是否合法时间 //OSPHP.COM.Cn开源 $timeArr=explode(":",$time); if(is_numeric($timeArr[0])&&is_numeric($timeArr[1])&&is_numeric($timeArr[2])){ //oSPHP.COM.CN if(($timeArr[0]>=0&&$timeArr[0]<=23)&&($timeArr[1]>=0&&$timeArr[1]<=59)&&($timeArr[2]>=0&&$timeArr[2]<=59)) //开源OSPhP.COM.CN returntrue; else returnfalse; } returnfalse; } functionDateDiff($date1,$date2,$unit=""){//时间比较函数,返回两个日期相差几秒、几分钟、几小时或几天 //开源OSPhP.COM.CN switch($unit){ case's': $dividend=1; break; case'i': $dividend=60; //OSPHP.COm.CN break; case'h': $dividend=3600; break; case'd': $dividend=86400; break; //OSPHP.COM.Cn开源 default: $dividend=86400; } $time1=strtotime($date1); $time2=strtotime($date2); if($time1&&$time2) //PHP开源代码 return(float)($time1-$time2)/$dividend; returnfalse; } ?> ······网站推荐:http://www.osphp.com.cn/read.php/323.htm#entrymore
- 2021-02-11 14:10:52