Location: PHPKode > scripts > Page highlighter > page-highlighter/oo_file.inc.php
<?

/**
 *   Make php-file Object-Oriented
 * 
 */
class File
{
    /**
	* 
	* Create a new File handle
	* 
	* @param $path which file to open also http and ftp works 
	* @param $mode how to open (r, r+, w, w+, o, o+)
	*  
	*/
	function File( $path , $mode)
    {
        $this->fh=fopen( $path, $mode );
    }
	

	/**
	*
	* Write some text into the file
	* 
	* @param $text the text to be writen, shown as is ; no newline
	* 
	*/
    function write( $text )
    {
        fwrite( $this->fh , $text );
    }

	/**
	* 
	* Write some text to the file with automatic Linefeed
	* 
	* @param $text the text to be writen with linefeed
	* @see write ist limilar
	* 
	*/
    function writeln( $text )
    {
        $this->write( $text."\n" );
    }


	
	
	/**
	* 
	* read a block of text
	* 
	* @param $len how much text
	*/
    function read( $len=4096)
    {
        return fread( $this->fh, $len );
    }
	
	
    /**
     * read a line from the file
	 * 
	 * @param $len how much of text 
     *
     **/
    function readline( $len=4096)
    {
        return fgets( $this->fh, $len );
    }
    
    /**
     * read a line and strip html comments, can be used for crawler 
     *
	 * @param $len how much data 
     **/
    function readline_striphtml( $len=4096 )
    {
        return fgetss( $this->fh, $len );
    }
    
    /**
     * close the file and clear the handle 
     *
     **/
    function close()
    {
        fclose( $this->fh );
        $this->fh="";
    }
    
    /**
     * Returns if this is end of file
	 * 
     * @access public
     * @return boolean is it end fo file
     **/
    function eof()
	{
    	return feof( $this->fh);
    }
    
}
?>
Return current item: Page highlighter