What if we store the echo variable content in a variable?

Source: Internet
Author: User
What if we store the echo variable content in a variable? This post was last edited by u011552243 at 20:08:40

Php echo email

Problem background: I want to output a table and send it as content by email.
Problem: add the code first,
 $message = '
 
 

'; $message.= 'Driver: '; $message.= $firstName.' '.$lastName; $message.= '

Date:'.$orderTime.'

No: 1

Car'.$truck.':'.' '.$licNum; $message.= '

Kund:'.$customerName.'

Order:'.$orderNum.'

'; $message.= 'Book number:'.$bookNumPick.'

Produktnamn:'.$productName.'

Chassi:'; $message.= $tankName.'

Tank number:'.$chassi.'

Place:'.$locationPick.'

Place 2:'; $message.= $portCodePick.'

Place 3:'.$locationUnload.'

Place 4:'; $message.= $timeUnload.'

Place 5:'.$ADRclass.'

Place 5:'.$weight.'

Place 6:'; $message.= $locationLoad.'

Place 7:'.$loadTime.'

Place 8:'; $message.= '

'.$info.'

Place 9:'.$outE.'

Place 10:'.$bookNumOut.'

Place 11:'; $message.= $portCodeOut.'

'; echo $message."
"; $to = $email; $subject = "Task"; $from = EMAIL; $headers = "From: $from"; echo $headers."
"; mail($to,$subject,$message,$headers);

I used double quotation marks at first. later, to ensure that the content in $ message is kept in double quotation marks, I changed the outer double quotation marks to single quotation marks.

In fact, I want the email content to be the result of echo $ message. However, the mail () function is used to send $ message Directly. The result is:

.... (Omitted, visible $ message ).....


Directly sends the content in $ message instead of the result after echo $ message.
What should I do?
Thank you very much for your convenience.


Reply to discussion (solution)

Problem background: I want to output a table and send it as content by email.
Problem: add the code first,

 $message = '
 
 

'; $message.= 'Driver: '; $message.= $firstName.' '.$lastName; $message.= '

Date:'.$orderTime.'

No: 1

Car'.$truck.':'.' '.$licNum; $message.= '

Kund:'.$customerName.'

Order:'.$orderNum.'

'; $message.= 'Book number:'.$bookNumPick.'

Produktnamn:'.$productName.'

Chassi:'; $message.= $tankName.'

Tank number:'.$chassi.'

Place:'.$locationPick.'

Place 2:'; $message.= $portCodePick.'

Place 3:'.$locationUnload.'

Place 4:'; $message.= $timeUnload.'

Place 5:'.$ADRclass.'

Place 5:'.$weight.'

Place 6:'; $message.= $locationLoad.'

Place 7:'.$loadTime.'

Place 8:'; $message.= '

'.$info.'

Place 9:'.$outE.'

Place 10:'.$bookNumOut.'

Place 11:'; $message.= $portCodeOut.'

'; echo $message."
"; $to = $email; $subject = "Task"; $from = EMAIL; $headers = "From: $from"; echo $headers."
"; mail($to,$subject,$message,$headers);

I used double quotation marks at first. later, to ensure that the content in $ message is kept in double quotation marks, I changed the outer double quotation marks to single quotation marks.

In fact, I want the email content to be the result of echo $ message. However, the mail () function is used to send $ message Directly. The result is:

.... (Omitted, visible $ message ).....


Directly sends the content in $ message instead of the result after echo $ message.
What should I do?
Thank you very much for your convenience.

Solved by yourself. $ Headers = "From: $ from". "\ r \ n ";;
$ Headers. = "MIME-Version: 1.0 \ n". "Content-type: text/html; charset = UTF-8 '";
You can. Close the post.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.