<?php // example 01 : simple open and close
require_once( "cfile.class.php" );
echo "<b>EXAMPLE 01</b>: simply creating, opening and closing a file<br><br>" ;
$CANDIDATEfile = "cfile.test.example01.txt" ;
$cfile = new cfile( $CANDIDATEfile );
$bOPEN = $cfile->open( CFILE_READWRITE_CREATE_MODE );
$bERR = $cfile->is_error() ;
if ( $bOPEN && !$bERR ) // you can check open return value or internal error for safe operation
{
echo "OPEN FILE $CANDIDATEfile : SUCCESS<br>" ;
echo ( $cfile->close() ) ? "CLOSE FILE $CANDIDATEfile : SUCCESS" : $cfile->get_error_string() ;
}
else echo $cfile->get_error_string() ;
?>
|