很多站长朋友们都不太清楚php删除html页面,今天小编就来给大家整理php删除html页面,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 怎么去除php页面中的HTML标签啊 2、 PHP 如何获取当前URL并去掉.html 3、 php如何清除html格式并去除文字中的空格然后截取文字 4、 PHP删除文章时同时删除生成的HTML页面 5、 php中一个html页面实现增删改查 6、 PHP如何可靠的去除HTML标签。。 怎么去除php页面中的HTML标签啊//去掉html标签
$string = preg_replace ( "/(\<[^\<]*\>|\r|\n|\s|\[.+?\])/is", ' ', $string );
//转义html标签
$string = htmlspecialchars ( $string );
PHP 如何获取当前URL并去掉.html很简单啊:
<?php
//
第一步:你需要得到你的URL:
$URL=$_SERVER['HTTP_HOST']
.
$_SERVER['REQUEST_URI'];
//第二步:把得到的URL后面的“.HTML”去掉:
$geturl=str_replace('.html','',$URL);
echo
$geturl;
?>
但是,可但是:
你的这个页面应该是php的才对吧,如果是html的,就一定是应用了拟静态技术来重写URL,这样的话,上面的代码你也可以使用,如果是生成的
静态页面
,那么很不好意思,这个基本上不可行了。也无法达到你的意愿。
php如何清除html格式并去除文字中的空格然后截取文字PHP清除html、css、js格式并去除空格的PHP函数
01 function cutstr_html($string,$length=0,$ellipsis='…'){
02 $string=strip_tags($string);
03 $string=preg_replace('/\n/is','',$string);
04 $string=preg_replace('/ |/is','',$string);
05 $string=preg_replace('/ /is','',$string);
06 preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/",$string,$string);
07 if(is_array($string)!empty($string[0])){
08 if(is_numeric($length)$length){
09 $string=join('',array_slice($string[0],0,$length)).$ellipsis;
10 }else{
11 $string=implode('',$string[0]);
12 }
13 }else{
14 $string='';
15 }
16 return $string;
17 }
php 去除html标签 js 和 css样式
01 function clearHtml($content){
02 $content=preg_replace("/<a[^>]*>/i","",$content);
03 $content=preg_replace("/<\/a>/i","",$content);
04 $content=preg_replace("/<div[^>]*>/i","",$content);
05 $content=preg_replace("/<\/div>/i","",$content);
06 $content=preg_replace("/<!--[^>]*-->/i","",$content);//注释内容
07 $content=preg_replace("/style=.+?['|\"]/i",'',$content);//去除样式
08 $content=preg_replace("/class=.+?['|\"]/i",'',$content);//去除样式
09 $content=preg_replace("/id=.+?['|\"]/i",'',$content);//去除样式
10 $content=preg_replace("/lang=.+?['|\"]/i",'',$content);//去除样式
11 $content=preg_replace("/width=.+?['|\"]/i",'',$content);//去除样式
12 $content=preg_replace("/height=.+?['|\"]/i",'',$content);//去除样式
13 $content=preg_replace("/border=.+?['|\"]/i",'',$content);//去除样式
14 $content=preg_replace("/face=.+?['|\"]/i",'',$content);//去除样式
15 $content=preg_replace("/face=.+?['|\"]/",'',$content);//去除样式 只允许小写 正则匹配没有带 i 参数
16 return $content;
17 }
PHP删除文章时同时删除生成的HTML页面添加文章时生成HTML静态的页面 但如果要删除文章 添加文章时生成的HTML静态页面也应该同时删除掉 否则就成了冗余文件 所以我们应该在删 除没用的文章时 同时删除掉已生成的HTML静态页面 下面来看看PHP文章系统里面如何同时删除掉生成的HTML静态页面 这里只是一个简单的原理系 统 可以作为一个参考 更成熟系统可以参考比较成熟的CMS系统 下面是源码文件
ob_start();
require_once(" /inc/conn php");
$id=$_GET["id"];
$path=$_GET["path"];
$sql="delete from newscontent where newsid=$id";
mysql_query($sql);
if(file_exists(" /newslist/$path"))
{
unlink(" /newslist/$path");
$foldername=substr($path );
$folder=fopen(" /newslist/$foldername");
$n= ;
while($f=readdir($folder))
{
if($f<>" " $f<>" ")
{
$n++;
}
}
closedir();
if($n== )
{
rmdir(" /newslist/$foldername");
}
}
header("location:del php");
?>
这些代码比较容易理解 ob_start();开启缓存 require_coce(" /conn php");包含数据库连接文件 下面的变 量$id $path都是接受传过来的页面 这两个值是在列表页面里面传递过来的 再往下执行的是SQL的删除语句 先将数据库里面的文章进行删除掉 下 面的if语句是删除静态页面的重要判断语句 如果$path存在的话 用unlink删除掉 而这里的while语句是读取的目录 不需要深入理解
lishixinzhi/Article/program/PHP/201311/20910
php中一个html页面实现增删改查增加:insert into 表名(字段1,字段2,...) values('值1','值2',....) where 条件;
删除:delete 表名
修改:update 表名 set 字段名='值' where 条件;
查询:select 字段名 from 表名 where 条件;
PHP如何可靠的去除HTML标签。。经测试...strip_tags就可以去掉啊
况且他把<script language='JavaScript'>
都去掉了
即使留着document.write("<img src='/data/upload/help/202303/02/3f18d915c937c8054864a88681adde8e.gif'/>");也无法起到作用的啊
关于php删除html页面的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于php删除html页面 php删除按钮的详细内容...