Jump to content

Recommended Posts

  • 2 weeks later...

I'm not sure if you're asking how to display the image using php instead of html but if so... this is how to do it:

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

 

[/span][span style=\"color:#007700\"]echo ([/span][span style=\"color:#DD0000\"]\"<img src=\\"[/span][span style=\"color:#0000BB\"]boat[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]jpg[/span][span style=\"color:#007700\"]&[/span][span style=\"color:#FF8000\"]#092;\">\");

 

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

You have to use the \ before the quotes in the html so that the server understands that they are not part of the php code. Hope this helps. (note: in the code above, the group of characters after "jpg" and before ">"); should actually be a forward slash "\".... I'm not sure why it wouldn't show up as a forward slash)

Link to comment
https://forums.phpfreaks.com/topic/2175-dynamic-images/#findComment-7215
Share on other sites

if you want to display an image depending on a var, do it like this:

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$image [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"image.jpg\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<img src=$image>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]?>

[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

the reason you do it like this is that PHP outputs in the form of HTML. in HTML typing in <img src=image.jpg> will include the image, so that's how you do it in PHP.

Link to comment
https://forums.phpfreaks.com/topic/2175-dynamic-images/#findComment-7240
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.