在php中要过滤一些特殊字符或非法字符我们可以有很多的办法,像正则表达式str_replace就是一个不错的办法,像回车,空格,换行都可以用它来解决。
近负责的一个系统模块终于可以说是接近尾声了,余下的工作就是配合测试们测试和修改了。
趁着这个相对比较闲的时间里,偷偷写几篇博文记录下这个时间段遇到的问题和我的解决方案(还是说解决方法吧)。
好了,废话不多说,进入正题。
有这种需求的一般都是去小偷程序那些,像去掉原页面的链接什么的。不过,我遇到的是要导出制定页面到word,安全起见需要去掉js代码块,先上代码:
- $searchRegex = array(
- '/<as*.*?s*>(s*.*?s*)</a>/i', // 超链接
- '/<scripts*.*?s*>[sS]*?</script>/i', // JS脚本代码
- );
- $replaceStr = array(
- '$1',
- ''
- );
- $content = preg_replace($searchRegex, $replaceStr, $content);
php的话这个就比较简单了,就是使用了preg_replace这个函数啦,不多说。。。需要注意的是两个正则吧,这个才是关键,代码如下:
- $regexForLink = '/<as*.*?s*>(s*.*?s*)</a>/i'; // 超链接
- $regexForJS = '/<scripts*.*?s*>[sS]*?</script>/i'; // JS脚本代码
如果要过滤HTML代码、空格、回车换行符,代码如下:
- function DeleteHtml($str)
- {
- $str = trim($str);
- $str = strip_tags($str,"");
- $str = ereg_replace("t","",$str);
- $str = ereg_replace("rn","",$str);
- $str = ereg_replace("r","",$str);
- $str = ereg_replace("n","",$str);
- $str = ereg_replace(" "," ",$str);
- return trim($str);
- }
过滤html中所有html标签可以使用strip_tags() 函数剥去 HTML、XML 以及 PHP 的标签。
strip_tags(string,allow)
好了,就这么多,希望下一次有帮助吧。
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php清除html中超链接/JS脚本/回车
波比源码 » php清除html中超链接/JS脚本/回车
levaquin 250mg price levofloxacin price
tadalis canada avana cheap voltaren 50mg ca
cheap bupropion strattera buy online seroquel 100mg without prescription
salbutamol sale imuran 100mcg ca viagra us
itraconazole buy online sporanox 100 mg price tinidazole canada
glycomet buy online order glucophage pills cialis overnight shipping
buy amlodipine is cialis generic buy cialis 20mg
clozaril pills oral clozaril 100mg decadron 0,5 mg for sale
tadalafil 5mg tablet viagra overnight shipping purchase sildenafil without prescription
order cialis 20mg pills viagra 150mg brand sildenafil 50mg
losartan 50mg over the counter order esomeprazole 20mg pills topamax price
lioresal online ozobax for sale online buy ketorolac for sale
sumatriptan 25mg cheap levaquin online order buy dutasteride pill
purchase tadalafil cialis 10mg oral order cipro 500mg
order generic cefuroxime 250mg bimatoprost drug robaxin online order
real casino slot machine games online blackjack spins website order tadalafil 40mg pill
paper help stromectol 12mg us stromectol 12 mg
sildalis brand sildenafil 100mg for sale lamictal 200mg ca
buy prednisone 5mg order isotretinoin 20mg without prescription buy amoxil 1000mg pill
live dealer blackjack real money casino online cialis 10mg tablet
order furosemide 100mg pills doxycycline 200mg pills plaquenil 400mg cheap
buy tadacip order diclofenac pill purchase indomethacin without prescription
buy naproxen 250mg generic buy prevacid online order lansoprazole 30mg without prescription
buy albuterol 100 mcg online cheap order protonix 40mg sale buy generic cipro
tiotropium bromide over the counter minocycline 100mg usa order hytrin 1mg without prescription
purchase actos actos 15mg pill order viagra 100mg sale
cialis 5mg for sale Cialis overnight delivery red dog casino
ivermectin 6mg for sale cheap stromectol 12mg order dapsone 100 mg pill
nifedipine 10mg pills aceon over the counter purchase fexofenadine pills
mesalamine buy online buy mesalamine 800mg online cheap irbesartan 150mg canada
olmesartan 20mg for sale depakote drug divalproex 250mg generic
lanoxin 250 mg oral micardis order online molnunat usa
cheap amoxicillin pill stromectol pill where to buy stromectol online
coreg 6.25mg for sale order coreg pills order amitriptyline 50mg sale
purchase dapoxetine online dapoxetine 90mg without prescription motilium uk
buy fosamax online ibuprofen 600mg canada order ibuprofen sale
indomethacin 50mg uk purchase flomax sale buy cenforce 50mg generic
buy pamelor 25 mg generic order panadol 500mg for sale purchase paroxetine online cheap
doxycycline online buy methylprednisolone 4mg over counter methylprednisolone online
buy pepcid 20mg for sale purchase prograf without prescription remeron 15mg pill
tricor drug buy fenofibrate pill female viagra cvs
esomeprazole uk order lasix 100mg online furosemide 40mg oral
provigil 100mg pills cheap stromectol 12mg buy promethazine online
buy clomid 100mg prednisolone 20mg canada prednisolone drug
order prednisone 5mg online prednisone 10mg cheap amoxil 250mg generic
isotretinoin 40mg drug buy ampicillin 500mg without prescription ampicillin 250mg canada
erectile dysfunction pills over the counter pregabalin price proscar 5mg for sale
fda ivermectin deltasone 40mg brand deltasone 40mg canada
buy ondansetron 8mg order ondansetron 4mg online cheap bactrim 960mg without prescription
order isotretinoin online cheap buy amoxicillin 250mg sale azithromycin online
order ventolin 2mg generic synthroid 100mcg sale order augmentin 375mg online cheap
prednisolone pills neurontin 100mg tablet furosemide price
provigil 100mg usa buy metoprolol 50mg lopressor online order
doxycycline uk buy vibra-tabs online order zovirax without prescription
avodart 0.5mg uk cephalexin 500mg sale xenical sale
order imuran for sale azathioprine 50mg tablet naprosyn online order
zocor 20mg for sale phenergan without prescription sildenafil in usa
order dapsone 100mg online buy avlosulfon 100mg generic order atenolol 100mg pills
cheap sildenafil tablets free cialis samples tadalafil 40mg price
promethazine 25mg drug order modafinil 100mg sale cialis 40mg oral
levaquin 500mg over the counter purchase zyban for sale zyban 150mg without prescription
buy generic cenforce for sale buy generic aralen over the counter purchase glucophage generic
order lexapro 20mg online purchase escitalopram pills naltrexone 50mg generic
buy tadalafil 5mg without prescription sildenafil for men low cost ed pills
ivermectin 3mg tab deltasone price accutane ca
order provigil generic cheap phenergan prednisone generic
amoxicillin online oral zithromax 250mg prednisolone usa
order gabapentin 800mg pill doxycycline 200mg tablet buy generic vibra-tabs
purchase serophene sale buy hydroxychloroquine 200mg without prescription buy plaquenil pills for sale
buy doxycycline without prescription monodox ca augmentin 1000mg drug
purchase tenormin for sale buy atenolol medication letrozole 2.5 mg sale
oral levothyroxine cost clomiphene order generic levitra
generic lisinopril 5mg order prilosec 20mg generic order metoprolol 50mg pills
buy hyzaar without prescription buy topamax 100mg pill topiramate 200mg generic
imitrex 50mg oral buy avodart for sale buy avodart for sale
buy sumycin 500mg pill buy cyclobenzaprine 15mg online oral baclofen 10mg
ketorolac pill colchicine uk cheap propranolol
flomax 0.4mg pills spironolactone medication order aldactone 100mg
order duloxetine 20mg pill buy cymbalta generic piracetam 800 mg tablet
cheap betnovate 20gm purchase betamethasone creams sporanox price
order generic ipratropium 100mcg buy ipratropium generic purchase zyvox pill
prometrium order online zyprexa 10mg for sale olanzapine 10mg oral
nateglinide without prescription captopril 25 mg price order candesartan generic
order bystolic 20mg generic order diovan 160mg pill oral clozapine 100mg
tegretol where to buy order lincocin without prescription purchase lincomycin pill
order diflucan sale ampicillin 500mg for sale cipro cost
purchase estrace without prescription estradiol tablet minipress where to buy
metronidazole 200mg for sale keflex 500mg price buy generic keflex
oral vermox order tadalafil generic purchase tadalafil generic
clindamycin us order erythromycin 500mg sale cost sildenafil 50mg
buy indocin 75mg capsule terbinafine where to buy suprax 100mg over the counter
amoxicillin 500mg generic clarithromycin 500mg over the counter buy clarithromycin generic
clonidine 0.1 mg price meclizine online buy oral spiriva 9 mcg
brand suhagra buy sildenafil 100mg sale sildalis online buy
minocin 100mg tablet minocycline 50mg tablet brand pioglitazone 15mg
isotretinoin 10mg price buy amoxicillin generic brand azithromycin 500mg
cialis pills 20mg cialis 40mg without prescription order cialis
azithromycin 250mg price purchase gabapentin for sale gabapentin oral
buy stromectol usa order prednisone online brand prednisone 5mg
oral lasix order albuterol generic albuterol cost
Thank you for great article. Hello Administ .Onwin , Onwin Giriş , Onwin Güncel Giriş , Tiklayin. Onwin
purchase vardenafil sale buy vardenafil 20mg for sale buy plaquenil tablets
altace 10mg uk glimepiride online buy order arcoxia 120mg without prescription
temovate price clobetasol online buy cordarone online order