Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gustavo de Arruda Paes  >  File Helper  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Exemple
Class: File Helper
Read and write data in files
Author: By
Last change:
Date: 2010-01-24 04:32
Size: 686 bytes
 

Contents

Class file image Download
<?php
header
("Content-Type: text/html; charset=UTF-8");

require 
"../files.helper.class.php";

// Define o path e o arquivo que serão trabalhados
$FileHelper->path(".")->file("teste.txt");

// Exibe o conteúdo atual
echo "<pre>{$FileHelper->read()}</pre>";

// Escreve um novo conteudo
$FileHelper->content("Hello!\n");

// Exibe o conteúdo atual
echo "<pre>{$FileHelper->read()}</pre>";

// Concatena com mais alguma coisa
$FileHelper->append("\nAnd more!")->save();

// Exibe o conteúdo atual
echo "<pre>{$FileHelper->read()}</pre>";

// Remove o arquivo
$FileHelper->delete();

// verifica se houve algum erro
if( ! empty($FileHelper->error) )
{
    exit( 
$FileHelper->error );
}