PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

PHP Source Code


Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,511 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,926 people online right now. Registration is fast and FREE... Join Now!





Read file

Function to read or delete a file

Submitted By: Fcomax
Actions:
Rating:
Views: 116

Language: PHP

Last Modified: July 3, 2009
Instructions: file_rd ($file, $mode)

$text = the text to read or delete
$mode = "read" or "delete"

//$mode:
// -read return the file content
// -delete to delete the file

Snippet


  1. <?php
  2. function file_rd ($file, $mode) {
  3.         if ($mode == "read") {
  4.                 $file_text=file_get_contents($file);
  5.                 return $file_text;
  6.                 }
  7.         else if ($mode == "delete") {
  8.                 unlink ($file);
  9.                 return true;
  10.                 }
  11.         else {
  12.                 return 0;
  13.                 }
  14. }
  15. ?>

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month