Where should HTML formatting be used?
Posted: Thu Apr 12, 2012 7:40 pm
Newbie to PHP here. I am well versed in HTML and CSS, but I have a simple question about where to use HTML formatting, when writing PHP.
When using a simple string variable in an echo statement, should I:
In other words, should I use the below:
Or this:
I apologize if the semantics of my question are confusing; I tried to make it as clear as possible.
Thank you in advance for any help.
-Matthew
When using a simple string variable in an echo statement, should I:
- Format the string in the definition of the variable, or;
- Format the variable in the echo statement (which will ultimately display the value of the variable)?
In other words, should I use the below:
Code: Select all
$variable = "This is an example.";
echo "<h1>$variable</h1>Code: Select all
$variable = "<h1>This is an example.</h1>";
echo "$variable"Thank you in advance for any help.
-Matthew