当前位置:  编程技术>php
本页文章导读:
    ▪php网页后退不再出现过期       <?php  ob_start();  if(function_exists(session_cache_limiter)) { session_cache_limiter("private, must-revalidate");  }  session_start()  ?>  ......
    ▪php+dojo 的数据库保存拖动布局的一个方法dojo 这里下载       看老大介绍的dojo框架,学习着写了下。刚开始学习php 请大家指教下!发现发不了附件。发两个代码大家自己体会了。 代码如下:<?php  session_start();  if ($_SESSION['gh']==''){  header('location:lo.........
    ▪php下实现农历日历的代码       代码如下:php农历日历 <?   ###########################################   #作者: 沈潋(S&S Lab)                      #   #E-mail:shenlian@hotmail.com              #   #web: http://www.fo.........

[1]php网页后退不再出现过期
    来源: 互联网  发布时间: 2013-11-30
<?php 
ob_start(); 
if(function_exists(session_cache_limiter)) { session_cache_limiter("private, must-revalidate"); 

session_start() 
?> 

    
[2]php+dojo 的数据库保存拖动布局的一个方法dojo 这里下载
    来源: 互联网  发布时间: 2013-11-30
看老大介绍的dojo框架,学习着写了下。刚开始学习php 请大家指教下!发现发不了附件。发两个代码大家自己体会了。
代码如下:

<?php 
session_start(); 
if ($_SESSION['gh']==''){ 
header('location:login.php');  

include("config.php"); 
$sql="select * from module";  
$result=mssql_query($sql,$conn); 
$num=mssql_num_rows($result); 
//echo $num; 
?> 
<style type="text/css">  
<!--  
#container0 {  
border:1px dotted #990033; 
height: 10px; 
margin: 10px;  

-->  
</style> 
<script type="text/javascript" src="/blog_article/include/dojo.js"></script> 
<script type="text/javascript"> 
//引用以下两个dojo包  
dojo.require("dojo.style"); 
dojo.require("dojo.dnd.*"); 
function init(){ 
  //利用classname取到元素列表,将其注册为dojo.dnd.HtmlDragSour 
  var arr=dojo.html.getElementsByClass('divdrag') 
  for(var i=0;i<arr.length;i++){ 
   var parentDiv=arr.parentNode.id 
   new dojo.dnd.HtmlDragSource(arr,parentDiv);    
  } 
  //定义容器  
new dojo.dnd.HtmlDropTarget("container0", ["container0",<?php for ( $p = 1 ; $p <= $num ; $p ++) { 
echo '"'.'container'.$p.'"'; 
if ($p != $num){ 
  echo ","; 

  } 
  echo ']); ';   

  for ($p =1 ; $p <=$num ;$p++){ 
  echo chr(13).'new dojo.dnd.HtmlDropTarget("container'.$p.'", ["container0",'; 
   for ($o =1 ;$o <= $num;$o++){ 
  echo '"container'.$o.'"'; 
  if ($o != $num){ 
   echo ","; 
  }   

  echo ']); ';   
  } 
  echo chr(13); 

  ?> 
}   
//增加到window.onload事件中 
window.onload=function(){init();} 
function bjsave() { 
gr="" 
<?php 
$sql='select id from module'; 
$result=mssql_query($sql,$conn); 
while($myrow=mssql_fetch_array($result)) 
echo 'if (mokuai'.$myrow['id'].'.parentElement.id !="container0") {'.chr(13).'gr=gr+'.$myrow['id'].'+"|"+ mokuai'.$myrow['id'].'.parentElement.id+ "$"'.chr(13).'}'.chr(13); 
?> 
form1.gr.value=gr; 
form1.submit(); 

</script> 
<div id="overDiv" ></div> 
<div id="container0"> 
<?php 
$sql='select * from module where id not in (select mokuaiid from geren where gh ='.$_SESSION['gh'].')'; 
$result=mssql_query($sql,$conn); 
while($myrow=mssql_fetch_array($result)) 
echo '<span  id="mokuai'.$myrow['id'].'"  title="'.$myrow['mmark'].'">'.$myrow['mn'].'</span>'; 
?> 
</div> 
<table width="98%" border="1" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td width="150" valign="top"> 
<?php 
for ($p=1; $p<=$num;$p=$p+2){  
  echo '<div id="container'.$p.'" >'; 
  $sql='select mokuaiid from geren where biaogeid='.$p.' and gh ='.$_SESSION['gh']; 
  $result=mssql_query($sql,$conn); 
  while($myrow=mssql_fetch_array($result)){ 
   $sql='select * from module where id='.$myrow['mokuaiid']; 
   $result1=mssql_query($sql,$conn);    
   while($myrow1=mssql_fetch_array($result1)){ 
    echo '<span  id="mokuai'.$myrow1['id'].'"  title="'.$myrow1['mmark'].'">'.$myrow1['mn'].'</span>'; 
   } 
  }      
  echo '</div>';  
}   
?></td> 
    <td width="150" valign="top"> 
<?php 
for ($p=2; $p<=$num;$p=$p+2){  
  echo '<div id="container'.$p.'" >'; 
  $sql='select mokuaiid from geren where biaogeid='.$p.' and gh ='.$_SESSION['gh']; 
  $result=mssql_query($sql,$conn); 
  while($myrow=mssql_fetch_array($result)){ 
   $sql='select * from module where id='.$myrow['mokuaiid']; 
   $result1=mssql_query($sql,$conn);    
   while($myrow1=mssql_fetch_array($result1)){ 
    echo '<span  id="mokuai'.$myrow1['id'].'"  title="'.$myrow1['mmark'].'">'.$myrow1['mn'].'</span>'; 
   } 
  }      
  echo '</div>';  
}   
?> 
</td>  
  </tr> 
</table> 
<input type="button" name="Submit" value="保存布局" onclick="bjsave();" /> 
<form id="form1" name="form1" method="post" action="/blog_article/savegr.html"> 
<input name="gr" type="hidden" value="" /> 
</form> 




代码如下:

<?php 
session_start(); 
if ($_SESSION['gh']==''){ 
header('location:login.php');  

include("config.php"); 
$sql='delete from geren where gh='.$_SESSION['gh']; 
mssql_query($sql); 
$gr=str_replace("container","",$_POST['gr']); 
//echo $gr; 
$array = explode("$", $gr); 
for ($i=0;$i<=count($array)-2;$i++){ 
$add=explode("|",$array[$i]); 
$sql='insert into geren (mokuaiid,biaogeid,gh) values ("'.$add[0].'","'.$add 
[1].'","'.$_SESSION['gh'].'")'; 
//echo $sql.'<br>'; 
mssql_query($sql); 

header("location:view.php"); 
?> 

dojo 这里下载 http://download.dojotoolkit.org/release-0.3.1/dojo-0.3.1-ajax.zip

    
[3]php下实现农历日历的代码
    来源: 互联网  发布时间: 2013-11-30
代码如下:

php农历日历

<?
  ###########################################
  #作者: 沈潋(S&S Lab)                      #
  #E-mail:shenlian@hotmail.com              #
  #web: http://www.focus-2000.com           #
  #                                         #
  #版权声明:                                #
  #作者开放版权                             #
  #允许无条件地使用本文件的全部或部分       #
  #可作任何修改或增补                       #
  #如果您使用了本文件,请给作者写一封E-mail #
  #如有问题欢迎同作者联系                   #
  #谢谢您的关注!                            #
  ###########################################

  /*
   *修改:小许
   *mail: san@xfocus.org
   *web : http://www.xfocus.org
   *
   *说实在的,我对古历可以说一窍不通,下面这个数组还是不理解 可是作者的信箱好像不通
   *基本上是依样画葫芦,所以出现错误,见笑见笑,呵呵
   */

  #农历每月的天数
  $everymonth=array(
                    0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1),
                    1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2),
                    2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3),
                    3=>array(5,29,30,29,30,29,29,30,29,29,30,30,29,30,10,4),
                    4=>array(0,30,30,29,30,29,29,30,29,29,30,30,29,0,1,5),
                    5=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,2,6),
                    6=>array(4,29,30,30,29,30,29,30,29,30,29,30,29,30,3,7),
                    7=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,4,8),
                    8=>array(0,30,29,29,30,30,29,30,29,30,30,29,30,0,5,9),
                    9=>array(2,29,30,29,29,30,29,30,29,30,30,30,29,30,6,10),
                    10=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,7,11),
                    11=>array(6,30,29,30,29,29,30,29,29,30,30,29,30,30,8,12),
                    12=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,9,1),
                    13=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,10,2),
                    14=>array(5,30,30,29,30,29,30,29,30,29,30,29,29,30,1,3),
                    15=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,2,4),
                    16=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,3,5),
                    17=>array(2,30,29,29,30,29,30,30,29,30,30,29,30,29,4,6),
                    18=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,5,7),
                    19=>array(7,29,30,29,29,30,29,29,30,30,29,30,30,30,6,8),
                    20=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,7,9),
                    21=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,8,10),
                    22=>array(5,30,29,30,30,29,29,30,29,29,30,29,30,30,9,11),
                    23=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,10,12),
                    24=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,1,1),
                    25=>array(4,30,29,30,29,30,30,29,30,30,29,30,29,30,2,2),
                    26=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,3,3),
                    27=>array(0,30,29,29,30,29,30,29,30,29,30,30,30,0,4,4),
                    28=>array(2,29,30,29,29,30,29,29,30,29,30,30,30,30,5,5),
                    29=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,6,6),
                    30=>array(6,29,30,30,29,29,30,29,29,30,29,30,30,29,7,7),
                    31=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,8,8),
                    32=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,9,9),
                    33=>array(5,29,30,30,29,30,30,29,30,29,30,29,29,30,10,10),
                    34=>array(0,29,30,29,30,30,29,30,29,30,30,29,30,0,1,11),
                    35=>array(0,29,29,30,29,30,29,30,30,29,30,30,29,0,2,12),
                    36=>array(3,30,29,29,30,29,29,30,30,29,30,30,30,29,3,1),
                    37=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,4,2),
                    38=>array(7,30,30,29,29,30,29,29,30,29,30,30,29,30,5,3),
                    39=>array(0,30,30,29,29,30,29,29,30,29,30,29,30,0,6,4),
                    40=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,7,5),
                    41=>array(6,30,30,29,30,30,29,30,29,29,30,29,30,29,8,6),
                    42=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,9,7),
                    43=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,10,8),
                    44=>array(4,30,29,30,29,30,29,30,29,30,30,29,30,30,1,9),
                    45=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,2,10),
                    46=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,3,11),
                    47=>array(2,30,30,29,29,30,29,29,30,29,30,29,30,30,4,12),
                    48=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,5,1),
                    49=>array(7,30,29,30,30,29,30,29,29,30,29,30,29,30,6,2),
                    50=>array(0,29,30,30,29,30,30,29,29,30,29,30,29,0,7,3),
                    51=>array(0,30,29,30,30,29,30,29,30,29,30,29,30,0,8,4),
                    52=>array(5,29,30,29,30,29,30,29,30,30,29,30,29,30,9,5),
                    53=>array(0,29,30,29,29,30,30,29,30,30,29,30,29,0,10,6),
                    54=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,1,7),
                    55=>array(3,29,30,29,30,29,29,30,29,30,29,30,30,30,2,8),
                    56=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,3,9),
                    57=>array(8,30,29,30,29,30,29,29,30,29,30,29,30,29,4,10),
                    58=>array(0,30,30,30,29,30,29,29,30,29,30,29,30,0,5,11),
                    59=>array(0,29,30,30,29,30,29,30,29,30,29,30,29,0,6,12),
                    60=>array(6,30,29,30,29,30,30,29,30,29,30,29,30,29,7,1),
                    61=>array(0,30,29,30,29,30,29,30,30,29,30,29,30,0,8,2),
                    62=>array(0,29,30,29,29,30,29,30,30,29,30,30,29,0,9,3),
                    63=>array(4,30,29,30,29,29,30,29,30,29,30,30,30,29,10,4),
                    64=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,1,5),
                    65=>array(0,29,30,29,30,29,29,30,29,29,30,30,29,0,2,6),
                    66=>array(3,30,30,30,29,30,29,29,30,29,29,30,30,29,3,7),
                    67=>array(0,30,30,29,30,30,29,29,30,29,30,29,30,0,4,8),
                    68=>array(7,29,30,29,30,30,29,30,29,30,29,30,29,30,5,9),
                    69=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,6,10),
                    70=>array(0,30,29,29,30,29,30,30,29,30,30,29,30,0,7,11),
                    71=>array(5,29,30,29,29,30,29,30,29,30,30,30,29,30,8,12),
                    72=>array(0,29,30,29,29,30,29,30,29,30,30,29,30,0,9,1),
                    73=>array(0,30,29,30,29,29,30,29,29,30,30,29,30,0,10,2),
                    74=>array(4,30,30,29,30,29,29,30,29,29,30,30,29,30,1,3),
                    75=>array(0,30,30,29,30,29,29,30,29,29,30,29,30,0,2,4),
                    76=>array(8,30,30,29,30,29,30,29,30,29,29,30,29,30,3,5),
                    77=>array(0,30,29,30,30,29,30,29,30,29,30,29,29,0,4,6),
                    78=>array(0,30,29,30,30,29,30,30,29,30,29,30,29,0,5,7),
                    79=>array(6,30,29,29,30,29,30,30,29,30,30,29,30,29,6,8),
                    80=>array(0,30,29,29,30,29,30,29,30,30,29,30,30,0,7,9),
                    81=>array(0,29,30,29,29,30,29,29,30,30,29,30,30,0,8,10),
                    82=>array(4,30,29,30,29,29,30,29,29,30,29,30,30,30,9,11),
                    83=>array(0,30,29,30,29,29,30,29,29,30,29,30,30,0,10,12),
                    84=>array(10,30,29,30,30,29,29,30,29,29,30,29,30,30,1,1),
                    85=>array(0,29,30,30,29,30,29,30,29,29,30,29,30,0,2,2),
                    86=>array(0,29,30,30,29,30,30,29,30,29,30,29,29,0,3,3),
                    87=>array(6,30,29,30,29,30,30,29,30,30,29,30,29,29,4,4),
                    88=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,5,5),
                    89=>array(0,30,29,29,30,29,29,30,30,29,30,30,30,0,6,6),
                    90=>array(5,29,30,29,29,30,29,29,30,29,30,30,30,30,7,7),
                    91=>array(0,29,30,29,29,30,29,29,30,29,30,30,30,0,8,8),
                    92=>array(0,29,30,30,29,29,30,29,29,30,29,30,30,0,9,9),
                    93=>array(3,29,30,30,29,30,29,30,29,29,30,29,30,29,10,10),
                    94=>array(0,30,30,30,29,30,29,30,29,29,30,29,30,0,1,11),
                    95=>array(8,29,30,30,29,30,29,30,30,29,29,30,29,30,2,12),
                    96=>array(0,29,30,29,30,30,29,30,29,30,30,29,29,0,3,1),
                    97=>array(0,30,29,30,29,30,29,30,30,29,30,30,29,0,4,2),
                    98=>array(5,30,29,29,30,29,29,30,30,29,30,30,29,30,5,3),
                    99=>array(0,30,29,29,30,29,29,30,29,30,30,30,29,0,6,4),
                    100=>array(0,30,30,29,29,30,29,29,30,29,30,30,29,0,7,5),
                    101=>array(4,30,30,29,30,29,30,29,29,30,29,30,29,30,8,6),
                    102=>array(0,30,30,29,30,29,30,29,29,30,29,30,29,0,9,7),
                    103=>array(0,30,30,29,30,30,29,30,29,29,30,29,30,0,10,8),
                    104=>array(2,29,30,29,30,30,29,30,29,30,29,30,29,30,1,9),
                    105=>array(0,29,30,29,30,29,30,30,29,30,29,30,29,0,2,10),
                    106=>array(7,30,29,30,29,30,29,30,29,30,30,29,30,30,3,11),
                    107=>array(0,29,29,30,29,29,30,29,30,30,30,29,30,0,4,12),
                    108=>array(0,30,29,29,30,29,29,30,29,30,30,29,30,0,5,1),
                    109=>array(5,30,30,29,29,30,29,29,30,29,30,29,30,30,6,2),
                    110=>array(0,30,29,30,29,30,29,29,30,29,30,29,30,0,7,3),
                    111=>array(0,30,29,30,30,29,30,29,29,30,29,30,29,0,8,4),
                    112=>array(4,30,29,30,30,29,30,29,30,29,30,29,30,29,9,5),
                    113=>array(0,30,29,30,29,30,30,29,30,29,30,29,30,0,10,6),
                    114=>array(9,29,30,29,30,29,30,29,30,30,29,30,29,30,1,7),
                    115=>array(0,29,30,29,29,30,29,30,30,30,29,30,29,0,2,8),
                    116=>array(0,30,29,30,29,29,30,29,30,30,29,30,30,0,3,9),
                    117=>array(6,29,30,29,30,29,29,30,29,30,29,30,30,30,4,10),
                    118=>array(0,29,30,29,30,29,29,30,29,30,29,30,30,0,5,11),
                    119=>array(0,30,29,30,29,30,29,29,30,29,29,30,30,0,6,12),
                    120=>array(4,29,30,30,30,29,30,29,29,30,29,30,29,30,7,1)
                   );
##############################
  #农历天干
  $mten=array("null","甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
  #农历地支
  $mtwelve=array("null","子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)",
                 "巳(蛇)","午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)");
  #农历月份
  $mmonth=array("闰","正","二","三","四","五","六",
                "七","八","九","十","十一","十二","月");
  #农历日
  $mday=array("null","初一","初二","初三","初四","初五","初六","初七","初八","初九","初十",
              "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
              "廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十");
##############################
  #星期
  $weekday = array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

  #阳历总天数 至1900年12月21日
  $total=11;
  #阴历总天数
  $mtotal=0;
##############################
  #获得当日日期
  $today=getdate();
  if($today["year"]<1901 || $today["year"]>2020) die("年份出错!");

  $cur_wday=$today["wday"];

  for($y=1901;$y<$today["year"];$y++) { //计算到所求日期阳历的总天数-自1900年12月21日始,先算年的和
       $total+=365;
       if ($y%4==0) $total++;
  }

  switch($today["mon"]) { //再加当年的几个月
         case 12:
              $total+=30;
         case 11:
              $total+=31;
         case 10:
              $total+=30;
         case 9:
              $total+=31;
         case 8:
              $total+=31;
         case 7:
              $total+=30;
         case 6:
              $total+=31;
         case 5:
              $total+=30;
         case 4:
              $total+=31;
         case 3:
              $total+=28;
         case 2:
              $total+=31;
  }

  if($today["year"]%4 == 0 && $today["mon"]>2) $total++; //如果当年是闰年还要加一天

  $total=$total+$today["mday"]-1; //加当月的天数

  $flag1=0;  //判断跳出循环的条件
  $j=0;
  while ($j<=120){  //用农历的天数累加来判断是否超过阳历的天数
      $i=1;
      while ($i<=13){
            $mtotal+=$everymonth[$j][$i];
            if ($mtotal>=$total){
                 $flag1=1;
                 break;
            }
            $i++;
      }
      if ($flag1==1) break;
      $j++;
  }

  if($everymonth[$j][0]<>0 and $everymonth[$j][0]<$i){ //原来错在这里,对闰月没有修补
      $mm=$i-1;
  }
  else{
      $mm=$i;
  }

  if($i==$everymonth[$j][0]+1 and $everymonth[$j][0]<>0) {
      $nlmon=$mmonth[0].$mmonth[$mm];#闰月
  }
  else {
      $nlmon=$mmonth[$mm].$mmonth[13];
  }

  #计算所求月份1号的农历日期
  $md=$everymonth[$j][$i]-($mtotal-$total);
  if($md > $everymonth[$j][$i])
      $md-=$everymonth[$j][$i];
  $nlday=$mday[$md];

  $nowday=date("Y年n月j日 ").$weekday[$cur_wday]."<br>".$mten[$everymonth[$j][14]].$mtwelve[$everymonth[$j][15]]."年".$nlmon.$nlday;
  echo "<font color=#3333ff>$nowday</font>";
?>

    
最新技术文章:
▪PHP函数microtime()时间戳的定义与用法
▪PHP单一入口之apache配置内容
▪PHP数组排序方法总结(收藏)
▪php数组排序方法大全(脚本学堂整理奉献)
▪php数组排序的几个函数(附实例)
▪php二维数组排序(实例)
▪php根据键值对二维数组排序的小例子
▪php验证码(附截图)
▪php数组长度的获取方法(三个实例)
▪php获取数组长度的方法举例
▪判断php数组维度(php数组长度)的方法
▪php获取图片的exif信息的示例代码
▪PHP 数组key长度对性能的影响实例分析
▪php函数指定默认值的方法示例
▪php提交表单到当前页面、提交表单后页面重定...
▪php四舍五入的三种实现方法
▪php获得数组长度(元素个数)的方法
▪php日期函数的简单示例代码
▪php数学函数的简单示例代码
▪php字符串函数的简单示例代码
▪php文件下载代码(多浏览器兼容、支持中文文...
▪php实现文件下载、支持中文文件名的示例代码...
▪php文件下载(防止中文文件名乱码)的示例代码
▪解决PHP文件下载时中文文件名乱码的问题
▪php数组去重(一维、二维数组去重)的简单示例
▪php小数点后取两位的三种实现方法
▪php Redis 队列服务的简单示例
▪PHP导出excel时数字变为科学计数的解决方法
▪PHP数组根据值获取Key的简单示例
▪php数组去重的函数代码示例
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3