hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Processed php into a php variable
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Processed php into a php variable

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-25-2007, 12:01 PM
Powi Powi is offline
WHT Addict
 
Join Date: Apr 2004
Posts: 167

Processed php into a php variable


Hi,

Say i have a php file that outputs html content.

Now I need to get that html (processed php) and store it into a variable so that i can send it in a email.

Can this be done?

Thanks!

Powi

__________________
cuartopunto.com

Reply With Quote


Sponsored Links
  #2  
Old 07-25-2007, 01:09 PM
Jatinder Jatinder is offline
Web Hosting Master
 
Join Date: Sep 2005
Location: India
Posts: 735
This should work:

PHP Code:
ob_start();

//Start generating HTML Code

echo "<html><body><h1>Hello World!</h1></body></html>";

//End

$html ob_get_contents();

ob_end_clean();

//Everything echoed out by your srcipt between calls
//to ob_start() and ob_get_contents() is now stored in variable $html 

__________________
Darsh Web Solutions : Web Design, PHP Development, E-Commerce Solutions

PHP Tutorials : Tutorials and scripts for beginners

Reply With Quote
  #3  
Old 07-26-2007, 05:33 PM
SagoMax SagoMax is offline
Junior Guru Wannabe
 
Join Date: Nov 2005
Location: Tampa, Florida
Posts: 59
If your provider doesn't have output buffering turned on..another way would be to store your "echo" commands into a variable instead and then output it at the end of your php script. I prefer to code this way as it is slightly more compatible across various server configurations.

For example:
Code:
$screen.='<html><body><h1>Hello World!</h1></body></html>';

/* Body of PHP script here */

echo $screen;

__________________
Max Rathbone - Systems Admin. - Sago Networks
http://www.sagonet.com
Click 'Live Support' on the website to have your questions answered!

Reply With Quote
Sponsored Links
  #4  
Old 07-27-2007, 05:28 AM
Jatinder Jatinder is offline
Web Hosting Master
 
Join Date: Sep 2005
Location: India
Posts: 735
Quote:
If your provider doesn't have output buffering turned on..
AFAIK output buffering does not need to be turned on.

The server admin may disabled the "ob_start/ob_get_contents" functions but I have never come across any host who does this. Nor is there any reason to disable these functions.

__________________
Darsh Web Solutions : Web Design, PHP Development, E-Commerce Solutions

PHP Tutorials : Tutorials and scripts for beginners

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Strategies to Reduce Operating Costs, Avoid Email Blacklisting and Improve Deliverability Webinars 2013-05-15 11:27:46
WHD.india 2013 Web Hosting Events 2013-05-22 13:02:04
A Cool DMCA Takedown Flowchart from Web Host Nexess Blog 2012-02-29 18:00:18
Digital Realty Trust Acquires Sacramento Data Center for $30 Million Web Hosting News 2011-10-06 14:23:39
The Variable Requirements of Data Center Vendor Selection: Andrew Schaap of Digital Realty Trust Web Hosting News 2011-09-27 15:06:29


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?