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. What Is Mkv? Need Help With This File Format?(9)
  2. Disable Task Manager 1 Line Code![vb6](33)
  3. Text File Operations VB.NET(6)
  4. You Cannot Create A File Named Con(10)
  5. Forum Based Multiplayer RPG(12)
  6. How We Resore The Old File.(2)
  7. PHP: Writing A Generic Login And Register Script(15)
  8. Super File Recover(3)
  9. Counter With Img In Flat File(2)
  10. Code To Send An Email From A Form(10)
  11. Free Code Snippets And Css Layout(14)
  12. How To Increase Windows Shutdown Speed(40)
  13. Does Anyone Code Using Turing(3)
  14. Deleting A Corrupt File(26)
  15. Read/Write Issues After Copying An Access .mdb File(3)
  1. Css File Size(7)
  2. Rapidshare(1)
  3. How To Create Exe File In Java?(13)
  4. How Do You Use The cPanel File Manager?(14)
  5. VB.NET: Howto Add And Delete Files(9)
  6. Restore Windows File And Folder Protection(5)
  7. Activation Code(7)
  8. How Can I Get From Iso To Usb, Without Writing A Cd?(5)
  9. Instant Replay Code?(0)
  10. Is A Php File Searchable?(8)
  11. Recover Tables From A MySQL .frm File(8)
  12. How To Copy File & Folders From Linux To Windows?.(12)
  13. Uploading Image File Through JSP Code To Server(9)
  14. Reading Xml Data(2)
  15. Php Random Selector(2)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 04:20 PM