Hi, maybe posting my code will help out a little. The code I am pulling with fread is actually on my server, just read as a URL instead. Some variables are left out, but you should get the idea.
$file_url = "$site_url/view_product.php?product=$product";
//get our new page's content
$file = fopen($file_url, "r");
if (!function_exists('file_get_contents')) {
$read = fread($file, 800000);
} else {
$read = file_get_contents($file_url);
}
$read = str_replace("src=images/", "src=".$site_url."/images/", $read);
$handle = $site_dir."/products/".$page_name;
//if the file doesnt already exsist, create it
if(!file_exists($handle)){
if (!$open = fopen($handle, "a")) { echo "Cannot open file"; }
if(!chmod($handle, 0755)){ echo "Cannot change permission on file."; }
if (!fwrite($open, $read)) { echo "Cannot write to file ".$handle."<br>"; }
} else {
echo "<center>File already exists.</center>"; exit;
}
Now, let's say I have this page called stuff.php now because of the above code. Now, what I want to do is add the below code to the end of my final $read variable, which is in all HTML but is a .php page.
$count = 0;
for($i=0;$i!=5;$i++){
$count++;
}
echo $count;
Now, what do you suggest as the best way to add my counter to the end of my last $read variable and have it work. Keeping it all in the same source page.
Thanks 🙂