<?php
$s_fname = "./about.php?id=37";
$o_fname = "htm/1.html";
ob_end_clean();
ob_start();
include($s_fname);
$length = ob_get_length();
$buffer = ob_get_contents();
//$buffer = eregi_replace("r","",$buffer);
ob_end_clean();$fp = fopen($o_fname,"w+");
fwrite($fp,$buffer);
fclose($fp);
?>
$s_fname = "./about.php?id=37";
$o_fname = "htm/1.html";
ob_end_clean();
ob_start();
include($s_fname);
$length = ob_get_length();
$buffer = ob_get_contents();
//$buffer = eregi_replace("r","",$buffer);
ob_end_clean();$fp = fopen($o_fname,"w+");
fwrite($fp,$buffer);
fclose($fp);
?>
你有另外两种选择
1是使用$buffer=file_get_contents('可访问的url来访问about.php?id=值');
2是修改about.php程序,引用定义的全局变量.
<?php
$s_fname = "./about.php?id=37";
$o_fname = "htm/1.html";
ob_end_clean();
ob_start();
include($s_fname);
$length = ob_get_length();
$buffer = file_get_contents();
//$buffer = eregi_replace("r","",$buffer);
ob_end_clean();$fp = fopen($o_fname,"w+");
fwrite($fp,$buffer);
fclose($fp);
?>
定义的全局变量.
什么意思啊如我的程式是<?
include("conn.php");
$id=$_GET[id];
$sql="select * from table id=$id"
$query=mysql_query($sql);
$row=mysql_fetch_array($query);
echo $row[title];?你说的定义的全局变量.
应该怎么做
把$buffer = ob_get_contents();换$buffer = file_get_contents();
不行啊!
$s_fname = "http://www.test.com/about.php?id=37";
$o_fname = "htm/1.html";
file_get_contents($s_fname,$buffer);
file_put_contents($o_fname,$buffer);
unset($buffer);
?>
<?php
$id=$_GET[id];
$s_fname = "./about.php";
$o_fname = "htm/1.html";
ob_end_clean();
ob_start();
include($s_fname);
$length = ob_get_length();
$buffer = ob_get_contents();
//$buffer = eregi_replace("r","",$buffer);
ob_end_clean();$fp = fopen($o_fname,"w+");
fwrite($fp,$buffer);
fclose($fp);
?>这样就搞定了
RewriteRule ^html/([0-9]+).html$ about.php?id=$1
</IfModule>
$s_fname = "http://www.test.com/about.php?id=37";
$o_fname = "htm/1.html";
file_get_contents($s_fname,$buffer);
file_put_contents($o_fname,$buffer);
unset($buffer);
?> 这代码不行--试了
<?php
$s_fname = "getid.php?id=1";
$o_fname = "htm/1.html";?>
<?php
ob_end_clean();
ob_start();
include($s_fname);$length = ob_get_length();
$buffer = ob_get_contents();
file_get_contents($s_fname,$buffer);
file_put_contents($o_fname,$buffer);
unset($buffer);
ob_end_clean();$fp = fopen($o_fname,"w+");
fwrite($fp,$buffer);
fclose($fp);
?>
$s_fname = "http://www.test.com/about.php?id=37";
$o_fname = "htm/1.html";
$buffer = file_get_contents($s_fname);
file_put_contents($o_fname,$buffer);
unset($buffer);
写的
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteRule ^html/([0-9]+).html$ about.php?id=$1 </IfModule>
什么意思啊
关键是干什么用
$s_fname = "get.php?aa=1";
$o_fname = "1.html";?>
<?php
ob_end_clean();
ob_start();
include($s_fname);
$buffer = file_get_contents($s_fname);
file_put_contents($o_fname,$buffer);
unset($buffer);
//$buffer = eregi_replace("r","",$buffer);
ob_end_clean();$fp = fopen($o_fname,"w+");
fwrite($fp,$buffer);
fclose($fp);
?><?php
$s_fname = "http://www.test.com/about.php?id=37";
$o_fname = "htm/1.html";
$buffer = file_get_contents($s_fname);
file_put_contents($o_fname,$buffer);
unset($buffer);
不对啊不知道你有没试,还是平想象来解答
<?php
// read.php// 判断 静态文件是否存在.存在直接跳转.
$id = $_GET['id'];
if(file_exists("./html/{$id}.html")){
header("Location: ./html/{$id}.html");
exit;
}
$src_url = "http://www.xxx.com/about.php?id={$i}";// 获取数据
$file_body = @file_get_contents($scr_url);
if($file_body){
// 有数据写静态文件
@file_put_contents("./html/{$id}.html", $file_body);
exit($file_body);
}else{
exit("get file error!");
}?>
你有另外两种选择
1是使用$buffer=file_get_contents('about.php?id=值');
如下方可:<?php
// read.php// 判断 静态文件是否存在.存在直接跳转.
$id = $_GET['id'];
if(file_exists("./html/{$id}.html")){
header("Location: ./html/{$id}.html");
exit;
}
$src_url = "http://www.xxx.com/about.php?id={$i}";// 获取数据
$file_body = @file_get_contents($scr_url);
if($file_body){
// 有数据写静态文件
@file_put_contents("./html/{$id}.html", $file_body);
exit($file_body);
}else{
exit("get file error!");
}?>
about.php<?
echo $_GET[id];
echo "aaaa";
?>aa.php<?php
// read.php // 判断 静态文件是否存在.存在直接跳转.
$id = $_GET['id'];
if(file_exists("./html/{$id}.html")){
header("Location: ./html/{$id}.html");
exit;
}
$src_url = "http://www.xxx.com/about.php?id={$i}"; // 获取数据
$file_body = @file_get_contents($scr_url);
if($file_body){
// 有数据写静态文件
@file_put_contents("./html/{$id}.html", $file_body);
exit($file_body);
}else{
exit("get file error!");
} ?>