I want to create tags using echo function but I’m stuck here; I dont know how to make it through.
This is what I want to do:
echo "<img src=$row['one'] style="width:100px"/>" ;
(Note: $row['one'] is a variable of php script and that contains the path of the image), but it throws me these error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\im.php on line 13
I want these statement to execute in php and I tried this way too:
echo '<img src=$row['one'] styel="width:100px" />';
These time I get the error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\im.php on line 13
I know where the error is. The error is most probably here
'<img src=$row[' //here's the error, right?
I worked on c and quite some other languages. I know that in c, to use double quotes in the printf we follow up some syntax but I dont know what to do in php.
You need to escape the
":or you use single quotes and do this:
There is never a need to concatenate in order to echo. You can always just use
,. The php manual explains the differences between'and"in the chapter on strings.As a goodie, because you mentioned printf, this works in php, too: