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);

Link to comment
Share on other sites

Do you really think each time you post a question on this forum a new page is created? Defeats the entire purpose of a database driven site.

 

Store your comments in a database and relate them to a topic via with a common id.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.