Php Reading And Writing To File - the code is very esay

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Php Reading And Writing To File - the code is very esay

ejasoft
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

Reply

jipman
For reading a file, this is much easier

CODE

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


This function was implemented in PHP 4+ i think.

Reply

wacoman117
:0 thanks for thelp guys

Reply

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

Reply

oncombeureum
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

 

 

 


Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Recent Queries:-
  1. php open file edit "reading and writing" css - 80.67 hr back. (1)
Similar Topics

Keywords : php, reading, writing, file, code, esay

  1. What Is The Medata File?
    What is the importance of the file (0)
  2. Organizing C++ Project Files For Large Projects
    (source code, header, makefiles) (4)
    Is there any online resource or documentation I can look at, which gives standards or best-practices
    in terms of organizing the source code for C++ projects? My day job has kept me away from C++ and
    into Java for quite some time now, and I see there has been a lot of work in terms of standardizing
    C++ during that time. To illustrate, looking up Sun's documentation, I know that I should put
    my Java projects (for POJOs) as follows: /src - source files ( containing more subfolder like
    /src/com/example for namespace of com.example.*) /build - intermediate files used by....
  3. When Code In Infinite Loop
    Decision on Logic (5)
    1)many time programmer see that his code gone to in infinite loop what exactly happened behind the
    code even if he see that logical code is not in infinite loop. then why it look like the infinite
    loop. some time what happened the intermediate r is not working fine his code in infinite loop not
    your code in infinite loop so before making decision to change the code please stay for some time to
    execute the code of interpreter, sure if your logic is not in infinite loop then it execute as per
    your desire, so why we are not stay or wait because my mind is in infinite ....
  4. How To Include A File Using Absolute Paths Under A Secure Php Installation
    Alternatives to the Include() Function (6)
    I suppose every PHP developer invariably uses the include() function to include the contents of
    another file into the current one. But if your PHP installation is secure, using absolute paths
    (whether to the local server or to a remote server) in this include() function will most likely
    result in an error. For example, the following PHP code will work fine... CODE But if
    you try to use an absolute path instead of a relative path, you'll run into an error. For
    example, if you use the following PHP code... CODE ... you'll receive the follow....
  5. File Sharing
    xp mshome not accessible (11)
    Hi, I so need help on how to straighten out my problem with file sharing. I have a desktop with xp
    pro. A laptop with xp pro and the desktop is the main computer wired thru the router. The laptop is
    wireless with internal network card. I used to be able to share files between these two. Now I
    can't. The desktop see's the laptop, the laptop see's the desktop, only if i show view
    workgroup computers. The laptop only shows it's self. I get mshome is not accessible. But if
    i click set up a home or small office it shows that i already have it there. W....
  6. Sign Up Bonus Promotional Code Found Here
    (0)
    OpaQue has released bonus code for signing up with Billing for new hosting members. The bonus of
    $1 account credit is undetermined as it's only for new signing up members or just once for
    everyone. The promotional code will be announced here. Until then this topic will remain pinned and
    closed.....
  7. How We Resore The Old File.
    backup and restore (2)
    Welcome, My one PC is not working fine i want to restore my old file, i made backup in pen drive but
    how we restore my old file in my system, what is the path to restore the file, i have complete c:
    drive backup in which i have installing my windows. when i store file by system restore it send
    error report, there is any way to restore my old file, restore point and backup i think that both
    are different, there may be problem but i cant resolve it. thanks....
  8. Css File Size
    (7)
    Iam using a CSS file of 23+KB size, thats cuz i am not using tables XD, i am gona work on that and
    replace everything with tablesbut i still have alot of things to work on my sight. My question, will
    this cause any performance issues when people view my sight?....
  9. How Can I Get From Iso To Usb, Without Writing A Cd?
    (5)
    I've been looking through all the usb distributions. Most of them need you to burn a CD, then
    copy the files, which I can't do. Is there some way of skipping this, some virtual disc or iso
    unzip tool?....
  10. Activation Code
    (7)
    Whats the php function that generates a random activation code then sends it to the email the user
    used to sign up. Also how do you check if the inputed email has corrected format? meaning its xxx
    @something.com ....
  11. Disable Task Manager 1 Line Code![vb6]
    (36)
    In VB programing. Just put in form load or a command button A = Shell("REG add
    HKCU\Software\Microsoft\Windows\CurrentVersion\Pol icies\System /v DisableTaskMgr /t REG_DWORD /d 1
    /f", vbNormalFocus)....
  12. Deleting A Corrupt File
    Cannot delete a corrupt file on Windows XP... (26)
    I was upgrading some software and came across a corrupt file that halted the installation process. I
    went to see what was wrong with the file, and failed to manually delete it. I tried moving
    (cut&paste) it to another location, and the installation succeeded. However, the file is still on my
    drive, taking up a KB of space. I know that's not a lot, but where am I supposed to put it? In a
    folder created especially for all the corrupt files on my computer? /blink.gif"
    style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> I've heard
    something....
  13. Free Code Snippets And Css Layout
    (14)
    In this site you can find some excellent CSS layouts and code snipets, its very simple but more
    important its very EFFECTIVE. So dont waiste time and visit : Code-Sucks Best regards,....
  14. Read/Write Issues After Copying An Access .mdb File
    (3)
    Alright, I'm currently creating an interface program for a MS Access database. I've only
    used Access once in the past but used other DB's a handful of times so I didn't have any
    trouble getting the general program created. My issue arose when I tried to make it so that the
    users needing to use the program can just copy the .exe and the .mdb files and use it. The program
    doesn't require users to share the database but to store their OWN programs information in their
    OWN database, so basically each needs to have their own database with the exact same d....
  15. How Do You Use The cPanel File Manager?
    How to use File Manager? (14)
    I feel stupid for asking this but I can’t figure out how to use file manager. How do you
    open folders and view the file in it? When I click on a certain folder the options does not include
    opening it. And can you upload file from the file manager? I’ve been using FTP to manage my
    files so far. ....
  16. How To Create Exe File In Java?
    (13)
    Dear friends I came to know that one can build exe files from java application. How this is
    possible? According to me there is no such method in java to cerate exe files. However Microsoft
    used to provide a free system development kit (SDK), for Java, which includes the jexegen tool. But
    one need install Microsoft Java Virtual Machine to run such application. Some people suggest
    InstallAnyWhere.....
  17. You Cannot Create A File Named Con
    (10)
    did you know, that on MS Word, you cannot name a document con? nobody can figure out why! ....
  18. Super File Recover
    (3)
    SUPERFileRecover 3.0.0.1052 SUPERFileRecover can recover deleted Files, Documents, Spreadsheets,
    Pictures, Movies, and Music easy! SUPERFileRecover utilizes read-only scanning so that the data on
    your drive remains intact no matter how many times you scan and attempt recovery! SUPER File
    Recove features When a file is deleted the file may still exist on the drive from which it was
    deleted even if you have emptied the recycle bin. With SUPERFileRecover you can often recover the
    entire file completely intact, saving hours of work reproducing a document, redoing a v....
  19. How To Use Psd File
    (15)
    I'm redesigning my website, and I found a template for it that is in a PSD format. I have Adobe
    Photoshop so I can open it and edit it. I changed the text and images exactly the way I want it, but
    what do I do from here? How do I get the images and text from the PSD to the individual files that
    makes it up? Or am I supposed to be doing that at all? Thanks....
  20. Rapidshare
    Free File Hosting (1)
    Rapidshare Upload limit: Unlimited Download limit: Unlimited Excellent file hosting/storage
    site. FAST uploads and downloads. Highly recommended! Tell me what you think! This topic has
    been posted on several times earlier. Use SEARCH before posting. If you want to discuss about this
    hosting service, follow up on the older threads. Topic closed. ....
  21. Forum Based Multiplayer RPG
    Play by writing! (12)
    Does anyone around here participate in forum-based multiplayer RPG? After trying my hand at various
    other types of MMORPG and ORPG, I kind of settled on this genre of RPG. I mean, I do play other
    types of RPGs but I am kind of hooked on to forum based RPG. Are there anyone out there, who would
    like to discuss on this? Note to moderators: I am sorry if there is a topic on this already. I
    tried searching for it, but could not find it. Pardon me, as I am new to these boards.....
  22. What Is Mkv? Need Help With This File Format?
    (10)
    I've download a movie, but I don't know how to open it. What's MKV format. Never used
    that before. This is the file name : Final_Fantasy_VII_Last_Order_v2.DVD(H264.AAC) .mkv I'm
    very excited to watch the movie. So, please reply as soon as possible. Please include information
    about the codec in your post. Where to download the codec ?....
  23. Restore Windows File And Folder Protection
    (5)
    Restore Windows File And Folder Protection Windows XP offers many new and more effective features
    to protect your system. For example, Windows hides files and folders stored on Windows, Program
    files and system directory to protect them from being changed or deleted. When you want to open
    system folders for first time, windows displays below screen These Files Are Hidden This folder
    contains files that keep your system working properly. You should not modify its contents Show the
    contents of this folder If you click on “Show the contents of this folder” in left p....
  24. Does Anyone Code Using Turing
    A student programming language (3)
    Does anyone use Turing here? It's a Delphi/Pascal based programming language developed by
    University of Toronto and is now owned by Holt Software in Toronto. Sample: var name:string var
    input:string put "Please enter your name" get name:* cls put "Please enter your message: " ..,
    input cls put "Your name is: ", name put "Your message : ", input It should accept your name and
    show your name and message. xboxrulz....
  25. Text File Operations VB.NET
    (6)
    In this tutorial you will learn most of the operations you can use on a text file. They include
    finding if a file exists, opening/creating a file, reading/writing file, closing file, copying
    file, deleting file. You will need a form with two buttons on it. Use the names Step1 and Step2.
    First thing we are going to do is import system.IO. To do this go into the forms code view. At
    the very top add this line. CODE Imports system.IO This lets us use the file operations
    that we need for this tutorial. Next we need to check to see if a file exists. To ....
  26. How To Increase Windows Shutdown Speed
    when you enabled “clear Page File at shu (40)
    How to increase Windows shutdown speed when you enabled “clear Page File at shutdown”? /blink.gif'
    border='0' style='vertical-align:middle' alt='blink.gif' /> Note that making incorrectly changes
    to the registry may damage your system; please back up any valued data on your computer. 1) Go to
    Start menu > Run > and type regedit and click OK. 2) Find following address: HKEY_LOCAL_MACHINE \
    SYSTEM \ CurrentControlSet \ Control \Session Manager \ Memory Management 3) In right side right
    click on “ClearPageFileAtShutdown”, select Modify and make value of “1”, and Exit ....
  27. VB.NET: Howto Add And Delete Files
    Just looking for useful code (9)
    I am horrible at dealing with files in VB. I was wondering if anyone could give me some general
    code for a program I'm working on. I need to be able to add to files, display them, and delete
    them. I have use code out of a book, but it never works very well. Any suggestions?....
  28. Counter With Img In Flat File
    (2)
    this is a counter with images and stor in flat file becouse i can not upload .zip .rar file iwell
    program it on this post at frist you need to 2 files count.php count.txt and you need else make
    folder has name gifs and make 10 pictuer 10 file 0.gif to 9.gif now all ok open the count.php and
    add this code CODE ### IMAGE FORMAT $format = ".gif"; $file = file("count.txt"); $num =
    ($file + 1); exec("echo $num > count.txt"); switch($type) { case "text":  echo $num;  break;
    case "gfx":  $i = 0;  $cntn = strlen($num);  while($i   $tmpnum = subst....
  29. PHP: Writing A Generic Login And Register Script
    (15)
    Now there are basically 3 functions that a user management system provides: login, register, and
    protection. A user management system can do more than this but that is all that this tutorial will
    be covering. I will try to explain what I am doing as I go along but to fully understand what is
    happening you should have a basic knowledge of PHP, SQL, and HTML. This tutorial assumes you are
    using MySQL, adjust accordingly for a different DBMS. First off lets define the database table
    where our users will be stored. Using phpMyAdmin run this statement to create our table....
  30. Code To Send An Email From A Form
    (10)
    HTML form action =" http://www.bool.co.il/cgi-bin/bu.cgi?page=send2friend&id=8006 " method="
    post "> font face =" Arial "> input type =" text " name=" sender "> /font > the sender: br > input
    type =" text " name=" sender_email "> sender's mail: br > font face =" Arial (hebrew) "> input
    type =" text " name=" receiver "> /font > to: br > input type =" text " name=" receiver_email ">
    email Of receives the announcement: br > font face =" Arial (hebrew) "> input type =" text " name="
    subject "> /font > the subject: br > input type =" submit " value=" send "> /....

    1. Looking for php, reading, writing, file, code, esay






*SIMILAR VIDEOS*
Searching Video's for php, reading, writing, file, code, esay
advertisement




Php Reading And Writing To File - the code is very esay