How do I put bot php and a string into the same variable?

  • Thread starter Thread starter slpcc63
  • Start date Start date
S

slpcc63

Guest
Im trying to do something like

$content = 'if(empty($_POST['name'])){
?>
<div id="valtext">*Please enter your name.</div>
<?php
}else{
<p>Thank you, your form has been submitted.</p>
}'

require_once('templateA.php')


And then in the middle of templateA.php there I have 'echo $content' to show my form w/ validation. The problem is, I dont know how to put both the string in the variable and not get an error. I dont know if it needs to all be in single quotes and i just need to put <?php ?> around my php, or if i should concatenate the html w/ . and put it in single quotes.


Thanks!
 
Back
Top