PHP Classes

File: example.php

Recommend this page to a friend!
  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: 14 years ago
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 );
}