<?php /** * 把一个指定的HTML页面显示。如果有页面中有放PHP代码的地方就执行PHP代码。 * 放置PHP代码的地方都有$fuhao1和$fuhao2 * @param unknown_type $filename * @param unknown_type $fuhao1 * @param unknown_type $fuhao2 */ function display2($filename,$fuhao1,$fuhao2,$xiandingarr){ $filestr=file_get_contents($filename); $ennable=false; $tmpstr=null; $isxianding=false; $biaojis=xiandingByArr($filestr, $xiandingarr); for ($i=0;$i<strlen($filestr);$i++){ $j=0; foreach ($biaojis as $biaoji) { if($biaoji[0]=$i){ $j=1; $isxianding=true; } } if($j==0){ $isxianding=false; } if($isxianding){ $ennable=false; } else if($filestr[$i]==$fuhao1){ $ennable=true; } else if($filestr[$i]==$fuhao2){ if($ennable){ $functioncode=substr($tmpstr, 1); $functionname=create_function("", "$functioncode;"); $functionname(); $ennable=false; $tmpstr=null; continue; } } if($ennable){ $tmpstr.=$filestr[$i]; } else{ echo $filestr[$i]; } } echo $tmpstr; } /** * 过滤指定的字符。使之不当做PHP代码 * @param unknown_type $str * @param unknown_type $xianding1 * @param unknown_type $xianding2 * @return multitype: */ function xianding($str,$xianding1,$xianding2){ $pos=-1; $resultarr=array(); while(!(($pos=strpos($str, $xianding1,$pos+1))===false)){ $tmppos=$pos; if(!(($pos=strpos($str, $xianding2,$pos+1))===false)){ echo $pos; $tmparr=array($tmppos,$pos+strlen($xianding2)); array_push($resultarr, $tmparr); } else{ break; } } return $resultarr; } /** * 根据数组中的数据来过滤,使之不当做PHP代码 * @param unknown_type $str * @param unknown_type $xiandingarr * @return multitype: */ function xiandingByArr($str,$xiandingarr){ $pos=-1; $resultarr=array(); foreach ($xiandingarr as $xian){ while(!(($pos=strpos($str, $xian[0],$pos+1))===false)){ $tmppos=$pos; if(!(($pos=strpos($str, $xian[1],$pos+1))===false)){ $tmparr=array($tmppos,$pos+strlen($xian[1])); array_push($resultarr, $tmparr); } else{ break; } } } return $resultarr; } $filestr=file_get_contents("include.html"); $xianarr=array( array(""), array("") ); print_r(xiandingByArr($filestr, $xianarr)); display2("include.html", "{", "}",$xianarr); ?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks agoByDDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks agoByDDD

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools
