Share on Google+Share on Google+

PHP function fopen and example

Advertisement
In this segment of PHP tutorial we will learn about the PHP fopen() function and its example

Syntax
file_handler fopen(file_name,file_mode,[path_include,[context]])

  • It opens the given file with the given mode and return the file handler
  • Using this file handler all other file handling functions can be done
  • In write (w) mode it creates a new file ,but not in read(r,r+),append(a)mode.


Example of PHP fopen() Function

Code for PHP fopen() Function
<?php
    $file1=fopen("c:/rose1/ram.txt","r");
    if
(!$file1)
      echo
"file is not existing ";
    else
      echo
"file exists";
?>
Output
file exists

Advertisements

Posted on: October 29, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.