PHP Classes

File: clasefilereplace.php

Recommend this page to a friend!
  Classes of markitos   filereplace   clasefilereplace.php   Download  
File: clasefilereplace.php
Role: ???
Content type: text/plain
Description: Main class
Class: filereplace
Replace signals using template file
Author: By
Last change:
Date: 21 years ago
Size: 924 bytes


Class file image Download
<? class filereplace { var $Fichero; var $Reemplazos=array(); function filereplace ($Fichero) { $this->Fichero = $Fichero; return $this; } function AddReplace ($Marca, $Reemplazo='') { $this->Reemplazos[$Marca]=$Reemplazo; return; } function RemoveReplace ($Marca) { unset ($this->Reemplazos[$Marca]); return; } function Replace() { $Retorno=''; $HFile = fopen ($this->Fichero, "r"); while (!feof ($HFile)) { $Retorno .= fread ($HFile, 1024); } fclose ($HFile); foreach ($this->Reemplazos as $Marca=>$Valor){ $Retorno = str_replace ($Marca, $Valor, $Retorno); } return $Retorno; } function Replace2File ($OutFile) { $Retorno=0; $Contenido=$this->Replace(); $HFile = fopen ($OutFile, "w"); if (!$HFile){ return $Retorno; } fwrite ($HFile, $Contenido); fclose ($HFile); if (file_exists ($OutFile)){ $Retorno=1; } return $Retorno; } } ?>