0

echo "<head></head><div style='float:left; padding:30px'><h1>$k['Name']</h1></br><img src='sponsor/".$k['Pic'].'.jpeg'."' height='300' width='300'><br>.</hr></div>";

The error occured after i wanted to echo $k['Name'];

This is the error that it shows
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

3
Contributors
3
Replies
31
Views
6 Days
Discussion Span
Last Post by diafol
0

Either concatenate the first variable or use braces to surround it. Concatenation is such a mess

0

In any case, this is HTML code, not PHP. You can put HTML in PHP class member variables and then output them in one shot, and this error should not occur. Do remember you still need to express the HTML code properly in the PHP variable.

0
echo "<head></head><div style='float:left; padding:30px'><h1>{$k['Name']}</h1></br><img src='sponsor/{$k['Pic']}.jpeg' height='300' width='300'><br></hr></div>";

Should work using braces. Use braces if you want to use array elements or class properties in strings but only if the string is enclosed in double quotes.

Edited by diafol

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.