Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Php Reading And Writing To File, the code is very esay
ejasoft
post May 2 2005, 11:24 PM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: Banned
Posts: 18
Joined: 2-May 05
Member No.: 4,656



this code to
Read from file
you can use this code in to make a small data base
and it is very to use
CODE

$fp = fopen ("file.txt", "r");
$bytes = 4;
$buffer = fread($fp, $bytes);
fclose ($fp);
print $buffer;


-------------------
to write to same file

CODE

$fp = fopen ("file.txt", "w+");
fwrite ($fp, "Test");
fclose ($fp);



----------------
thanks and iwait the commant

This post has been edited by microscopic^earthling: May 3 2005, 06:31 AM
Go to the top of the page
 
+Quote Post
jipman
post May 3 2005, 12:13 PM
Post #2


Pretty please?
Group Icon

Group: Members
Posts: 733
Joined: 28-November 04
From: Holland
Member No.: 1,552



For reading a file, this is much easier

CODE

$filedata = file_get_contents('filename.txt');


This function was implemented in PHP 4+ i think.
Go to the top of the page
 
+Quote Post
wacoman117
post May 14 2005, 08:17 PM
Post #3


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 12
Joined: 14-May 05
Member No.: 5,069



:0 thanks for thelp guys
Go to the top of the page
 
+Quote Post
JuseH
post May 15 2005, 02:01 AM
Post #4


Newbie [ Level 1 ]
Group Icon

Group: Banned
Posts: 6
Joined: 15-May 05
Member No.: 5,083



QUOTE(jipman @ May 3 2005, 09:13 AM)
For reading a file, this is much easier

CODE

$filedata = file_get_contents('filename.txt');


This function was implemented in PHP 4+ i think.
*



Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled.

<?
$dp = "http://www.vaila.net/v1/home.php";
if (!$dp)
{
echo("<P>Error: unable to load URL file into $dp. Process aborted.</P>");
exit();
}
$sp = file_get_contents($dp);
highlight_string($sp);
?>
Go to the top of the page
 
+Quote Post
oncombeureum
post May 21 2005, 03:20 AM
Post #5


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 28
Joined: 17-April 05
Member No.: 4,081



i implement this
QUOTE
<?
$fp = fopen('data.txt', 'r');

if ($fp) {
  while (!feof($fp)) {
      $texts = fread($fp, 4096);
  echo 'this is -> ' . $texts . '\n <br?';
  }
  fclose($fp);
}

?>


for the data file:
QUOTE
data.txt
satu@mon.com,
combo@bakso.com,
special@monyong.com,
kuya.batok@forever.and.ever.com,
special.pake.telor.2@tolong.jangan.lama.com


the result :
QUOTE
this is -> satu@mon.com combo@bakso.com special@monyong.com kuya.batok@forever.and.ever.com special.pake.telor.2@tolong.jangan.lama.com \n


what i want is
can it read line by line ?
no matter how long the line is

danke
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Script To Download File From Another Site(9)
  2. How Do I Create And Write To Files?(4)
  3. Online HTML/PHP Editor: Edit File In Browser!(8)
  4. PHP File Upload Works... But Stupid IE(3)
  5. Display Text If Line Not Empty In Config File(8)
  6. [PHP + MySQL] Separating The Results By Pages(0)
  7. PHP Script To Upload A File(13)
  8. Generating A Table Into A File In CSV Format(6)
  9. Sessions, Setting, Unsetting, Reading(5)
  10. How Can I Write PHP Code By This Formmail Html(5)
  11. Reading Data From Sessions(2)
  12. How To Embed Ram File Produced By Http Header(2)
  13. Xgrid With Php(0)
  14. Code Snippets Repository(0)
  15. Updating An Rss File Using A Php Form(1)
  1. File Self Secure?(6)
  2. How To Delete File Using PHP Shell Script(3)
  3. How To Force A Zip File To Be Downloaded(11)
  4. Automated File Structure Creation Script(3)
  5. Php File Upload(3)
  6. Extplorer(7)
  7. Reading Files And Folders(1)
  8. What's Wrong With My Php Webpage?(2)
  9. Writing And Testing My Own Login Script [solved](20)
  10. Dynamic Php Image And Better Php Code Question(10)
  11. Php Random Selector(2)
  12. Reading Xml Data(2)
  13. Activation Code(7)


 



- Lo-Fi Version Time is now: 30th August 2008 - 03:25 PM