PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ask2ksa
Forum Newbie
Posts: 2 Joined: Thu Apr 02, 2009 3:00 pm
Post
by ask2ksa » Thu Apr 02, 2009 3:10 pm
Hi
I am having trouble in displaying image using string variable in php as image is not displaying using below code:
Code: Select all
$string = '<img width=\"100\" height=\"100\" align=\"left\" src=\"path/to/image.jpg\" />';
echo "$string";
However image is displaying correctly using:
Code: Select all
echo "<img width=\"100\" height=\"100\" align=\"left\" src=\"path/to/image.jpg\" />";
Can some please guide me about this problem.
Mark Baker
Forum Regular
Posts: 710 Joined: Thu Oct 30, 2008 6:24 pm
Post
by Mark Baker » Thu Apr 02, 2009 3:20 pm
No need to escape the double quotes, because the whole variable is defined within single quotes:
Code: Select all
$string = '<img width="100" height="100" align="left" src="path/to/image.jpg" />';
echo $string;
And no need for the quote marks when echoing a variable
ask2ksa
Forum Newbie
Posts: 2 Joined: Thu Apr 02, 2009 3:00 pm
Post
by ask2ksa » Thu Apr 02, 2009 3:32 pm
Thanks I have checked it removing double quotes also but still same problem.
Mark Baker
Forum Regular
Posts: 710 Joined: Thu Oct 30, 2008 6:24 pm
Post
by Mark Baker » Thu Apr 02, 2009 3:51 pm
ask2ksa wrote: Thanks I have checked it removing double quotes also but still same problem.
So how does it appear in your HTML if you do a "View Source" in your browser?