smarty 模板中使用循环的语法是:
smarty 模板中使用循环的语法是:
分享一个同事写的URL正则表达式,缺点不支持中文URL:
(http[s]{0,1}|ftp)://[a-zA-Z0-9.-]+.([a-zA-Z]{2,4})(:d+)?(/[a-zA-Z0-9.-~!@#$%^&*+?:_/=<>]*)?
//此处,$res为数组,但是数组的维数不定,此时不能用count函数
//array_filter() 将删除 $res 中所有等值为 FALSE 的条目
$filter_res = array_filter($res);
我们核心代码就是正则表达试了
function get_all_url(http://pic3.phprm.com/2013/05/18/$code.jpg){
preg_match_all(‘/<as+href=["|']?([^>"' ]+)["|']?s*[^>]*>([^>]+)</a>/i’,$code,$arr);
return array(‘name’=>$arr[2],’url’=>$arr[1]);
}
方法一
if(preg_match("/^d*$/", "4312"))
{
echo "全数字
";
}
例1
<?php
$getUrl = (empty($_GET['url'])) ? './' : $_GET['url'].'/';
function fileName($dir)
{
$fileAll = scandir($dir,0);
$pathDir = $pathFile = array();
$count = count($fileAll);
if($count <= 2){
echo "空目录<br />";
}
foreach($fileAll as $pdf){
if(is_dir($dir.$pdf)){
$pathDir[] = $pdf;
}else{
$pathFile[] = $pdf;
}
}
foreach($pathDir as $pd){
if($pd == '.' or $pd == '..') continue;
echo "<a href="?url=$dir$pd">$pd</a><br />";
}
foreach($pathFile as $pf){
echo "<a href="$dir$pf" target="_blank">$pf</a><br />";
}
if($dir != './'){
$dir = rtrim($dir,'/');
$dir = explode('/',$dir);
unset($dir[sizeof($dir)-1]);
$dir = implode('/',$dir);
echo "<a href="?url=$dir">Go Back</a>";
}
}
fileName($getUrl);
列一
<?php
表单部分:
<form action="?action=edit_num" method="post" name="car<?php $c_rs['id'];?>" id="car<?php $c_rs['id'];?>">
cookie语法
int SetCookie(string name, string value, int expire, string path, string domain, int secure);
string strip_tags ( string str [, string allowable_tags] )
弊端 :
生成html原理分析
我们把要生成的标签写成一个模板文件,然后再利用php读取把指定标签替换成我们要替换 内容就可以了,现在主流的dedecms系统也是这么做的