PHP的小问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:22:17
<?php
$iyjt_sfjg=$_POST['iyjt_sfjg'];//浏览标题
$yyuj_sfjg=$_POST['yyuj_sfjg'];//文章标题
$go_idr=$_POST['go_idr'];//来源
$mwpw=$_POST['mwpw'];//内容
if($_POST['ti']=="提交"){
class sfj{//类sfj
var $a;//声明一个类变量$a
var $b;//声明一个类变量$b
function sfj($c = "bb.php"){//含数sfj里面的参数$c 赋值给e.html
$this -> a = $c;//赋值给变量 a 变量$a等于$c也就是e.html
}
function load(){//含数
$fs = fopen($this -> a,"r");// 打开e.html 文件
$v = fread($fs, filesize($this -> a));//然后读取e.html文件里面的内容,把内容 赋值给 变量 $v
fclose($fs);//关闭文件
$this -> b = $v;//把变量$v赋给类的变量$b
}
//函数 repl;
function repl($html_tgdn, $php_rep){
$this -> b = ereg_replace("\{".$html_tgdn."\}",$php_rep,$this -> b);
}//ereg_replace是替换用的.
}
$jfuj=date("Y-m-d H:i");//随系统生成
$html = new sfj();
$html -> load();

手册里有这样的例子
<?php

function callback($buffer)
{
// replace all the apples with oranges
return (str_replace("apples", "oranges", $buffer));
}

ob_start("callback");

?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php

ob_end_flush();

?>

我感觉可以的。。你试试

用file_get_contents()获得页面文件
用str_replace()或preg_replace()替换
然后再写入回去就行了吧……