我看过phpcms、discuz的源码,所以可能就缺乏创新了,不过原理大都相通,只是细节处理可能稍微不同。 说正题,下面开始谈谈具体实现过程了。 1.首先要想好模板文件放在哪?转换后的php文件放哪?还有怎么命名?直接上源码: 代码如下:function template($tpl = index,$dir = hello) { if(!file_exists($pd = TPL_PATH.$dir./))@mkdir($pd,0777) or die("$pd目录创建失败");//如cache/tpl/hello/ if(!file_exists($td = TPL.$dir./...
代码如下:/* author: ssh_kobe date: 20110602 shortage: 如果网页中的图片路径不是绝对路径,就无法抓取 */ set_time_limit(0);//抓取不受时间限制 $URL='http://pp.baidu.com/';//任意网址 get_pic($URL); function get_pic($pic_url) { //获取图片二进制流 $data=CurlGet($pic_url); /*利用正则表达式得到图片链接*/ $pattern_src = '//; $num = preg_match_all($pattern_src, $data, $match_src); $arr_src=$match_src[1];//获...
function template($tpl = 'index',$dir = 'hello'){if(!file_exists($pd = TPL_PATH.$dir.'/'))@mkdir($pd,0777) or die("$pd目录创建失败");//如cache/tpl/hello/if(!file_exists($td = TPL.$dir.'/'))@mkdir($td,0777) or die("$td目录创建失败");//如data/tpl/hello/$t2p = $pd.$tpl.'.php';//模板文件正则转换后形成的php文件,如cache/tpl/hello/index.php$t2h = $td.$tpl.'.html';//html模板文件,如data/tpl/hello/index.ht...
为大家介绍一段php代码,用于判断url地址并自动转换为超链接,在一段字符串中用正则表达式匹配出url,在将url转换为超链接,点击可访问地址。有需要的朋友参考下吧。代码如下:
代码如下:/* author: ssh_kobe date: 20110602 shortage: 如果网页中的图片路径不是绝对路径,就无法抓取 */ set_time_limit(0);//抓取不受时间限制 $URL='http://pp.baidu.com/';//任意网址 get_pic($URL); function get_pic($pic_url) { //获取图片二进制流 $data=CurlGet($pic_url); /*利用正则表达式得到图片链接*/ $pattern_src = '//'; $num = preg_match_all($pattern_src, $data, $match_src); $arr_src=$match_src[1];//获...
我看过phpcms、discuz的源码,所以可能就缺乏创新了,不过原理大都相通,只是细节处理可能稍微不同。 说正题,下面开始谈谈具体实现过程了。 1.首先要想好模板文件放在哪?转换后的php文件放哪?还有怎么命名?直接上源码: 代码如下:function template($tpl = index,$dir = hello) { if(!file_exists($pd = TPL_PATH.$dir./))@mkdir($pd,0777) or die("$pd目录创建失败");//如cache/tpl/hello/ if(!file_exists($td = TPL.$dir./...
一直都在网上抄别人写的电话,邮箱正则表达式,今天稍微有点闲情,把一直想自己写个这样的表达式的心愿给完成: 代码如下:/** * 邮箱地址正则表达式 */$preg = '/^(\w{1,25})@(\w{1,16})(\.(\w{1,4})){1,3}$/';$b = 'ffgddayasdadasdf@gmialsdfsdfasd3.com.cn.org';if(preg_match($preg, $b)){ echo "匹配到了";}else{ echo "没有匹配到";}http://www.bkjia.com/PHPjc/327780.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHP...
文章介绍了利用php正则表达式提取图片地址 超链接 标题 实现代码,有需要的朋友可参考一下。正则表达式提取网址中的id代码如下preg_match(/http://t.sina.com.cn/(d+)/fans//,$html,$result); 正则表达式提取网址中的id
echo $result[1];PHP的正则表达式提取图片地址的代码。代码如下$str=; $pattern="/<[img|IMG].*?src=[|"](.*?(?:[.gif|.jpg]))[|"].*?[/]?>/"; preg_match_all($pattern,$str,$match); print_r($match); PHP正...
正则表达式 代码如下:/* author: ssh_kobe date: 20110602 shortage: 如果网页中的图片路径不是绝对路径,就无法抓取 */ set_time_limit(0);//抓取不受时间限制 $URL='http://pp.baidu.com/';//任意网址 get_pic($URL); function get_pic($pic_url) { //获取图片二进制流 $data=CurlGet($pic_url); /*利用正则表达式得到图片链接*/ $pattern_src = '//'; $num = preg_match_all($pattern_src, $data, $match_src); $arr_src=$matc...
我看过phpcms、discuz的源码,所以可能就缺乏创新了,不过原理大都相通,只是细节处理可能稍微不同。 说正题,下面开始谈谈具体实现过程了。 1.首先要想好模板文件放在哪?转换后的php文件放哪?还有怎么命名?直接上源码: 代码如下:function template($tpl = index,$dir = hello) { if(!file_exists($pd = TPL_PATH.$dir./))@mkdir($pd,0777) or die("$pd目录创建失败");//如cache/tpl/hello/ if(!file_exists($td = TPL.$dir./...
代码如下:/* author: ssh_kobe date: 20110602 shortage: 如果网页中的图片路径不是绝对路径,就无法抓取 */ set_time_limit(0);//抓取不受时间限制 $URL='http://pp.baidu.com/';//任意网址 get_pic($URL); function get_pic($pic_url) { //获取图片二进制流 $data=CurlGet($pic_url); /*利用正则表达式得到图片链接*/ $pattern_src = '//'; $num = preg_match_all($pattern_src, $data, $match_src); $arr_src=$match_src[1];//获...
我看过phpcms、discuz的源码,所以可能就缺乏创新了,不过原理大都相通,只是细节处理可能稍微不同。 说正题,下面开始谈谈具体实现过程了。 1.首先要想好模板文件放在哪?转换后的php文件放哪?还有怎么命名?直接上源码: 代码如下:function template($tpl = index,$dir = hello) { if(!file_exists($pd = TPL_PATH.$dir./))@mkdir($pd,0777) or die("$pd目录创建失败");//如cache/tpl/hello/ if(!file_exists($td = TPL.$dir./...
一直都在网上抄别人写的电话,邮箱正则表达式,今天稍微有点闲情,把一直想自己写个这样的表达式的心愿给完成: 代码如下:/** * 邮箱地址正则表达式 */$preg = '/^(\w{1,25})@(\w{1,16})(\.(\w{1,4})){1,3}$/';$b = 'ffgddayasdadasdf@gmialsdfsdfasd3.com.cn.org';if(preg_match($preg, $b)){ echo "匹配到了";}else{ echo "没有匹配到";}
代码如下:<?php /* author: ssh_kobe date: 20110602 shortage: 如果网页中的图片路径不是绝对路径,就无法抓取 */ set_time_limit(0);//抓取不受时间限制 $URL='http://pp.baidu.com/';//任意网址 get_pic($URL); function get_pic($pic_url) { //获取图片二进制流 $data=CurlGet($pic_url); /*利用正则表达式得到图片链接*/ $pattern_src = '/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/'; $num = preg_ma...
我看过phpcms、discuz的源码,所以可能就缺乏创新了,不过原理大都相通,只是细节处理可能稍微不同。 说正题,下面开始谈谈具体实现过程了。 1.首先要想好模板文件放在哪?转换后的php文件放哪?还有怎么命名?直接上源码: 代码如下:function template($tpl = index,$dir = hello) { if(!file_exists($pd = TPL_PATH.$dir./))@mkdir($pd,0777) or die("$pd目录创建失败");//如cache/tpl/hello/ if(!file_exists($td = TPL.$dir./...