Rabastan Posted March 21, 2012 Share Posted March 21, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/ Share on other sites More sharing options...
Mahngiel Posted March 21, 2012 Share Posted March 21, 2012 This: <?php echo (IMAGES_HEADER . "header_02.jpg"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329944 Share on other sites More sharing options...
Rabastan Posted March 21, 2012 Author Share Posted March 21, 2012 Thank You for your reply, I think I edited the code the way you explained, I know have this.... <?php echo IMAGES_HEADER . "header_02.jpg"; ?> However I am getting the same result Rab Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329948 Share on other sites More sharing options...
Rabastan Posted March 21, 2012 Author Share Posted March 21, 2012 Got it to work, it seems I failed to load the file that defined "IMAGE_HEADER" Thanx Rab Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329950 Share on other sites More sharing options...
Rabastan Posted March 21, 2012 Author Share Posted March 21, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329953 Share on other sites More sharing options...
Mahngiel Posted March 21, 2012 Share Posted March 21, 2012 You still need to use valid HTML markup in order to call an image. PHP will only create what you tell it to, and in the case of your code, it's: images/header/header_02.jpg So put that information inside of an <img /> Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329956 Share on other sites More sharing options...
Rabastan Posted March 21, 2012 Author Share Posted March 21, 2012 Again THANK YOU SO MUCH. My last question is how to turn that into a link? Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329961 Share on other sites More sharing options...
Mahngiel Posted March 21, 2012 Share Posted March 21, 2012 http://www.tizag.com/htmlT/ Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329964 Share on other sites More sharing options...
Rabastan Posted March 21, 2012 Author Share Posted March 21, 2012 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. Rab Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329995 Share on other sites More sharing options...
smerny Posted March 21, 2012 Share Posted March 21, 2012 php outputs html Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1329996 Share on other sites More sharing options...
Psycho Posted March 21, 2012 Share Posted March 21, 2012 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/259443-how-do-i-make-this-work/#findComment-1330008 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.