Jump to content

Archived

This topic is now archived and is closed to further replies.

valentin

Html and php for images

Recommended Posts

I tried to use php with html in order to load an image
[code]<?php
$a="<img src=\"image.jpeg\">";
echo "$a";
?>[/code]

I know that php has its own header for loading an image, but I need a code which uses html. Mine doesn't work, does anyone know if a combination between html and php is possible, in this situation?
Thank you in anticipation!

Share this post


Link to post
Share on other sites
use like

echo("<img src=\"imageurl.ext\" />");

try this instead of putting it into a varible

Share this post


Link to post
Share on other sites
^wrong
[code]
<?php
$a="<img src=\'image.jpeg\'>";
echo "$a";
?>
[/code]

dude dont use doible quotes on double quotes if out side quotes are single quotes inside quotes will be double and vice versa

Share this post


Link to post
Share on other sites
wtf dude i do that all the time its all good thats the point of using \ slashes duh....

Share this post


Link to post
Share on other sites
the /> is for elements without a closing tag.  it is XHTML format.

as for the actual issue, why are you using quotes at all?  why not just use:

[code]echo $a;[/code]

furthermore, when setting a string that has no variables, you might as well use single quotes to delimit the expression:

[code]$a = '<img src="imagename.jpg" />';[/code]

if this doesn't solve your issue, you're going to need to be more specific with what you're asking.

Share this post


Link to post
Share on other sites
Indeed, you do not need to escape quotes if the ones inside the string are different from those containing the string.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.