Jump to content

How do I make this work?


Rabastan

Recommended Posts

I am using this line of code my site

 

<?php echo (IMAGES_HEADER . "header_02.jpg" ?>

 

I have a page defining all my directories, on that page I have this

 

 define('IMAGES_HEADER', DIR_IMAGES . 'header/');

 

instead of showing the image, all I am getting is "IMAGES_HEADERheader_02.jpg" where the image should be.

 

I am very new to PHP and trying to learn it, what in the world am I doing wrong??

 

Rab

 

Link to comment
Share on other sites

Now it seems I have a new problem using this code.....

 

<?php echo IMAGES_HEADER . "header_02.jpg"; ?>

 

Instead of displaying the actual image on my site I am getting the path of the image. It is displaying "images/header/header_02.jpg" instead.

 

Thank You in advance

Link to comment
Share on other sites

I know how to do it in HTML, I am trying to learn php and there for try to use as php as possible in this site, not just wrap php in html.

 

Your issue IS an HTML issue, not a PHP issue. If you know what the HTML markup should be then just use the PHP code to produce that markup. It doesn't happen automagically.

 

To output an image link in HTML

<a href="page_to_load.php"><img src="path/to/image.image.jpg"></a>

 

So, to do the same thing in PHP you can hard code the same thing or create variables for parts of the output

$href_url = "page_to_load.php";
$image_src = IMAGES_HEADER . "header_02.jpg";;
echo "<a href='{$href_url}'><img src='{$image_src}'></a>";

Link to comment
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.