Codice PHP:
function write_news($title, $text)
{
$fp=fopen('docs/private/text.txt', 'r');
$n=fread($fp, filesize('docs/private/text.txt'));
fclose($fp);
$fp=fopen('docs/private/title.txt', 'r');
$t=fread($fp, filesize('docs/private/title.txt'));
fclose($fp);
$search=array('à', 'è', 'ì', 'ò', 'ù');
$replace=array('à', 'è', 'ì', 'ò', 'ù');
$title=str_replace($search, $replace, $title);
$text=str_replace($search, $replace, $text);
$date=date('d/m/Y', time());
$date="[b]".str_replace('/', ' ', $date)."[/b]";
$title=$date." - ".$title."\n".$t;
$text=$text."\n".$n;
$fp=fopen('docs/private/text.txt', 'w');
$fd=fopen('docs/private/title.txt', 'w');
fwrite($fp, $text);
fwrite($fd, $title);
fclose($fp);
fclose($fd);
return true;
}
Non so perchè questa funzione ogni volta che inserisco qualche testo prima dei caratteri ' e " mi mette degli escape \.
Per esempio la frase
Me la restituisce così:
Oggi non c(qui ci mette l'escape ma il forum me lo cancella...)'è