Jump to content

Recommended Posts

Ok I'm having an issue with a simple PHP Inlcude that I've never ran in to before. Maybe you guys can help.

I'm trying to include a picture simply titled 'promo1.jpg'.. I go about the normal PHP include way with this code:

<?php include $_SERVER['DOCUMENT_ROOT'] . '/images/promo1.jpg'; ?>

This proceeds to only output a question mark '?'. No error message. Nothing else. Just the server saying "What the hell?". I've tried not doing the DOCUMENT_ROOT route and tried more locally but still same '?'. Any ideas on this one? Any help is appreciated, thanks.

Link to comment
https://forums.phpfreaks.com/topic/240270-problem-with-php-include-outputs-a/
Share on other sites

Images (all media files) on a web page are fetched by the browser using a URL to that image/media.

 

You cannot include an actual image into a web page. You must use a HTML <img> tag in the markup of the page that lists the URL where the actual image can be fetched at - http://w3schools.com/html/html_images.asp

Ok I'm having an issue with a simple PHP Inlcude that I've never ran in to before. Maybe you guys can help.

I'm trying to include a picture simply titled 'promo1.jpg'.. I go about the normal PHP include way with this code:

<?php include $_SERVER['DOCUMENT_ROOT'] . '/images/promo1.jpg'; ?>

This proceeds to only output a question mark '?'. No error message. Nothing else. Just the server saying "What the hell?". I've tried not doing the DOCUMENT_ROOT route and tried more locally but still same '?'. Any ideas on this one? Any help is appreciated, thanks.

 

You can't include an image.

You have to echo image inside a html image tag.

That was simple.

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.