代码如下 | 复制代码 |
$filename = 'cachefile.php'; //写缓存文件 function createcache($filename,$str) //读取缓存文件 function readcache($filename) |
/*
本站原创文章,转载注明来源http://www.111cn.net/phper/php.html
*/
代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.111cn.net/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <head> <style type="text/css教程"> <!-- .menu { color:#000000; font-size: 12px; cursor: hand;} </style> <script type="text/网页特效"> function showmenu(menuid) { if(menuid.style.display=="none") { menuid.style.display=""; } else { menuid.style.display="none"; } } </script> <title>电视树状目录</title> </head> <body> <?php $globals["id"] =1; $jibie=1; $sql="select * from tvmenu where bid=0"; $result=mysql教程_query($sql,$conn); if(mysql_num_rows($result)>0) treemenu($conn,$result,$jibie,$id); function treemenu($conn,$result,$jibie) //进入函数循环 { $numrows=mysql_num_rows($result); echo "<table cellpadding='0' cellspacing='0' border='0'>"; for($rows=0;$rows<$numrows;$rows++) { $menu=mysql_fetch_array($result); $sql="select * from tvmenu where bid=$menu[id]"; $result_sub=mysql_query($sql,$conn); echo "<tr>"; //如果该菜单项目有子菜单,则添加javascript onclick语句 if(mysql_num_rows($result_sub)>0) { echo "<td width='20'><img" width=100% src='+.gif' border='0'></td>"; echo "<td class='menu' onclick='javascript:showmenu(menu".$globals["id"].");'>"; } else { echo "<td width='20'><img" width=100% src='-.gif' border='0'></td>"; echo "<td class='menu'>"; } if($menu[url]!="") echo "<a href='$menu[url]'>$menu[name]</a> "; else echo "<a href='#'>$menu[name]</a> <a href='?b={$menu[id]}&tpye=add'> 添加</a> <a href='?b={$menu[id]}&tpye=edit'> 编辑</a> <a href='?b={$menu[id]}&action=del'> 删除</a>"; echo "</td> </tr>"; if(mysql_num_rows($result_sub)>0) { echo "<tr id=menu".$globals["id"]++." style='display:none'>"; echo "<td width='20'> </td>"; echo "<td>"; //将级数加1 $jibie++; treemenu($conn,$result_sub,$jibie); $jibie--; echo "</td></tr>"; } //显示下一菜单 } echo "</table>"; } ?> <br /> <br /> <?php if ($tpye=="add") { ?> <table width="551" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc"> <form action="" method="post" name="form1"> <tr> <td height="28" colspan="2" align="center" bgcolor="#ffffff">添加栏目</td> </tr> <tr> <td width="246" height="28" align="right" bgcolor="#ffffff">栏目名称:</td> <td width="302" height="28" bgcolor="#ffffff"><input name="name" type="text" id="name" /></td> </tr> <tr> <td height="28" align="right" bgcolor="#ffffff">所属分类:</td> <td height="28" bgcolor="#ffffff"><select name="bid"> <?php $sql="select * from tvmenu"; $que=mysql_query($sql,$conn); while($rs=mysql_fetch_array($que)){ if ($rs['id']==$b) { $selected="selected="selected""; }else{ $selected=""; } ?> <option value="<?php echo $rs["id"]; ?>" <?php echo $selected;?>><?php echo $rs["name"]; ?></option> <?php }?> </select> </td> </tr> <tr> <td height="28" colspan="2" align="center" bgcolor="#ffffff"><input type="submit" name="submit" value="提 交" /></td> </tr> </form> </table> <?php }?> |
这是一款php 截取字符串函数哦,支持中文字符串哦,它可以截取html与中西文,等混合的内容,并且把html标签不算在字符截取之内,如果html标签没有闭合,程序将自动过滤多余的标签。
代码如下 | 复制代码 |
function mysubstr( $str, $length ){ for( $i = 0; $i < $length; $i++ ){ $resultstr .= $str[$i]; for( $j=$i; $str[$j]!='>'; $j++,$length++ ){ $tag = ''; $charcnt++; //栈是空的直接返回 $tag = array_pop($tagstack); $index = strrpos($resultstr, $tag); for($i = $index-1; $resultstr[$i] != '>'; $i++ ){ $resultstr[$i++] = ''; return $resultstr; $sttime = microtime(true); $stmem = memory_get_usage(); $str = "a1<body>b2<p>c3<em>d4</em>e5</p>f6</body>g7h8"; echo '处理结果为:<br/><hr size=1>',htmlspecialchars( mysubstr( $str, 18 ) ),'<br />'; echo "内存使用情况:",(memory_get_usage()-$stmem),'<br />'; echo "算法运行时间(microtime):",(microtime(true)-$sttime),'<br/>'; |
//方法二
/
代码如下 | 复制代码 |
** echo '<xmp>'; |
/*
create table `member` (
`member_account` varchar(25) collate utf8_unicode_ci not null,
`member_password` varchar(32) collate utf8_unicode_ci not null,
`member_name` varchar(20) collate utf8_unicode_ci not null,
`sex` varchar(1) collate utf8_unicode_ci not null,
`schoolnumber` varchar(10) collate utf8_unicode_ci not null,
`phonenumber` varchar(15) collate utf8_unicode_ci not null,
`email` varchar(50) collate utf8_unicode_ci not null,
unique key `member_account` (`member_account`)
) engine=innodb default charset=utf8 collate=utf8_unicode_ci;
*/
?>
代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <body> register_get.php文件 |
代码如下 | 复制代码 |
$log = 'log/count.txt'; $fp = @fopen($log, "r+") or die($log.'数据文件不能打开!'); |