Re: Calling text files

From: Date: Tue, 17 Oct 2000 12:12:12 +0000
Subject: Re: Calling text files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-20597@lists.php.net to get a copy of this message
These are all great but I would recommend loading the text into a var and running functions like strip_tags(); This way you can make sure the user text doesnt mess up your page. This example gets the whole file into $contents and a few functions to get it ready to output. $filename = "/usr/local/something.txt"; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize($filename)); fclose ($fd); $contents = strip_tags($contents); // removes html and php tags $contents = wordwrap($contents , 70 , "\n" , 1); // cuts long words like ahhhhhh... that could stretch table cells $contents = nl2br($contents); // converts all \n (newlines) to <BR> echo $contents; That should do it, check http://www.php.net/strings for more string functions. SL. ----- Original Message ----- From: <Website4S@aol.com> To: <php-general@lists.php.net> Sent: Monday, October 16, 2000 11:59 PM Subject: [PHP] Calling text files > Hi, > > This is just a little question, but I just wanted to check it was possible > before I start programming. Is it possible to call a xxxx.txt file which > contains text to be displayed on a page, the reason I want to do it this way > is it would be easier for the site administrator to simply edit a text file > than to edit text in a .php file. > > Thanks for any info > > Ade > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#20597) next »