Page 1 of 1
$message = " "; gives error
Posted: Mon Feb 18, 2008 2:58 pm
by plodos
Code: Select all
$message= '
<table width="522" height="235" border="0">
<tbody>
<tr>
<td width="105" height="23" bgcolor="#CCCCCC">Name Surname: </td>
<td width="403" bgcolor="#CCCCCC">{$name} {$surname}</td>
</tr>
<tr>
<td height="23" valign="top">Institution:</td>
<td>{$institution}</td>
</tr>
</tbody>
</table>';
That code gives an error, I cant see the variables..output is like that
Name Surname: {$name} {$surname}
Institution:{$institution}
but it must be like that
Name Surname: Plodos MAmas
Institution:Software Group
Could you help me, whats the problem ?
and whats the output of this code
Code: Select all
<td width="403" bgcolor="#CCCCCC">{$name} {$surname}</td>
like Plodos Mamas or PlodosMamas(side by side)
Re: $message = " "; gives error
Posted: Mon Feb 18, 2008 3:11 pm
by Christopher
Try heredoc style:
Code: Select all
$message= <<<TABLE
<table width="522" height="235" border="0">
<tbody>
<tr>
<td width="105" height="23" bgcolor="#CCCCCC">Name Surname: </td>
<td width="403" bgcolor="#CCCCCC">{$name} {$surname}</td>
</tr>
<tr>
<td height="23" valign="top">Institution:</td>
<td>{$institution}</td>
</tr>
</tbody>
</table>
TABLE;
"TABLE" is a name that you make up to define the start/end of the block.
Re: $message = " "; gives error
Posted: Mon Feb 18, 2008 9:01 pm
by Stryks
Just as a side note to keep in mind, PHP doesn't do variable replacements on strings passed with a single quote.
... will produce
I am sleepy
.
.. will produce
I am $x
.
Attempting variable manipulation on HTML segments is a nightmare with double quotes, leaving you with 1001 escaped double slashes ....
Code: Select all
echo "<p class=\"myclass\">My nickname is \"$nickname\".</p>";
So heredoc to the rescue.
