how to include php if condition in html -


i have written php code convert html content pdf using mpdf api, want include php if condition in html content how can that? here code:

$cart_body='<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>new order placed</title> </head> <body> <table width="550" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="400" align="left" valign="top"> <a style="font-size:16px">' if(somecondition){ echo "somecontent"; } else{ echo "somecontent"; }'</a><br /> </body> </html>'; 

you can use . operator concatenation, see example below:

$cart_body='<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>new order placed</title> </head> <body> <table width="550" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="400" align="left" valign="top"> <a style="font-size:16px">'; if(somecondition){ $cart_body .= "somecontent"; } else{ $cart_body .= "somecontent"; }  $cart_body .= '</a><br /> </body> </html>'; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -