Jump to content

Question about how to write to a file a certain way?


Redlightpacket

Recommended Posts

Below I will tell you what I need help with.

 


// This reads the file into the array.
//Do I need a different method right here to put the array into a variable, so 
//the php and html contents in the file can be created into an another file.
$lines = file('http://www.talktopixk.com/post.php');



//Need something to look into the string and replace something in the file string.
//str_replace replaces a word in a string
$datastr = str_replace("tablestringdatastring", "test", $lines);



/////this set of code creates a comment1.php

///////////////////////////////////////////////////
$myFile = "comment1.php";
$fh = fopen($myFile, 'w');
$myFile = "comment1.php";
$fh = fopen($myFile, 'w') or die("can't open file");
///////////////////////////////////////////////////
//Write the name of the file.



$modFile = "comment1.php";

//But in the end this only writes the html contents and it tries to write php contents of the "post.php", but it don't which I want the PHP contents written to comment1.php file.
Why does it stop writing all of the php contents in the php "post.php" file and how can I 
can be able to write php and html contents together?

file_put_contents($modFile,$datastr);

fclose($fh);

I'm trying to create a comment system, which you make comments to a certain message on another page.

The new page that is created will have all of the new comments on it. The comments can keep on adding up.

 

What is a better way to do this?

Any body has any good ideas for me?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.