[PHP] HTML file to a $var: Pls Help
Any way to plug an entire HTML file into a variable? I looked into file_get_contents() but that was CVS format only. I need to take a simple HTML file and pass it as a string variable to a mail function. Any help? Thanks crew. - NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML file to a $var: Pls Help
Try this: implode ('', file ($filename)); On Fri, 2002-10-25 at 19:26, Shane wrote: Any way to plug an entire HTML file into a variable? I looked into file_get_contents() but that was CVS format only. I need to take a simple HTML file and pass it as a string variable to a mail function. Any help? Thanks crew. - NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML file to a $var: Pls Help
Hello, Shane [EMAIL PROTECTED] wrote: Any way to plug an entire HTML file into a variable? I looked into file_get_contents() but that was CVS format only. True. But you can make your own. Something like this: --- function file_get_contents($filename) { $fp = @fopen($filename, r); if (!($fp)) { return 0; } while (!feof($fp)) { $temp .= fread($fp, 4096); } return $temp; } That was from the manual: http://www.php.net/manual/en/function.file-get-contents.php Also, always check the User Contributed Notes for some good tips :) HTH, - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML file to a $var: Pls Help
There is another way to do this also... ob_start(); readfile($file); $var = ob_get_contents(); ob_end_clean(); If you want to parse the file before inputting it into the variable, instead of using readfile() use something like: eval(require(\.$file.\);); == eNetwizard Network http://www.enetwizard.net/default.ehtml == eNetwizard Content Management Server http://project.enetwizard.net/cmserver.ehtml == eNetwizard Managed Hosting Services http://hosting.enetwizard.net/hosting.ehtml == -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HTML file to a $var: Pls Help
There is another way to do this... ob_start(); readfile($file); $var = ob_get_contents(); ob_end_clean(); If you want to parse the file as PHP before inputting it into the variable, instead of using readfile() use this: eval(require(\.$file.\);); == eNetwizard Network http://www.enetwizard.net/default.ehtml == eNetwizard Content Management Server http://project.enetwizard.net/cmserver.ehtml == eNetwizard Managed Hosting Services http://hosting.enetwizard.net/hosting.ehtml == -Original Message- From: @ Edwin [mailto:copperwalls;hotmail.com] Sent: Friday, October 25, 2002 11:06 PM To: Shane Cc: [EMAIL PROTECTED] Subject: Re: [PHP] HTML file to a $var: Pls Help Hello, Shane [EMAIL PROTECTED] wrote: Any way to plug an entire HTML file into a variable? I looked into file_get_contents() but that was CVS format only. True. But you can make your own. Something like this: --- function file_get_contents($filename) { $fp = @fopen($filename, r); if (!($fp)) { return 0; } while (!feof($fp)) { $temp .= fread($fp, 4096); } return $temp; } That was from the manual: http://www.php.net/manual/en/function.file-get-contents.php Also, always check the User Contributed Notes for some good tips :) HTH, - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php