echoing AND storing in variable<

liunx

Guest
Can you echo something to the browser, AND store it in a variable in one line?

I have a page that creates a table dynamically with info from a database, I'd like to be able to E-Mail this table to someone by simply filling in their E-Mail, and clicking send. I figured that the best way to do that would be to make a variable $message = "<html>\r\n<body>\r\n<table>\r\n"; and then when I echo info to the table, have $message .= "table row info";
I'm already echoing out the table rows, and it seemed kind of a sloppy to duplicate each line:
echo "table data 1";
$message .= "table data 1";
echo "table data 2";
$message .= "table data 2";
etc.Originally posted by AaronCampbell
Can you echo something to the browser, AND store it in a variable in one line?

I have a page that creates a table dynamically with info from a database, I'd like to be able to E-Mail this table to someone by simply filling in their E-Mail, and clicking send. I figured that the best way to do that would be to make a variable $message = "<html>\r\n<body>\r\n<table>\r\n"; and then when I echo info to the table, have $message .= "table row info";
I'm already echoing out the table rows, and it seemed kind of a sloppy to duplicate each line:
echo "table data 1";
$message .= "table data 1";
echo "table data 2";
$message .= "table data 2";
etc.

just build $message first


$message = "<html>\r\n<body>\r\n<table>\r\n\";
$message .= "table data 1";
$message .= "table data 2";


and echo the variable instead of each line:


echo $message;
 
Back
Top