bdicasa Posted December 13, 2008 Share Posted December 13, 2008 Hey guys, I've mostly developed in ASP.NET before where you use ~ to refer to your home directory. Now that I need to develop in PHP I'm running into some confusion using include() and image URLs. I know how to use include using relative paths, but that doesn't seem like a good idea to me. I want to use include_path, however, I'm unsure how it works. I've tried changing my include path to 'C:\www' and then use the path name. E.g. if I have a file called register.php in C:\www\Classes\Business\register.php then I would use include('\Classes\Business\register.php'); however it does not seem to be working. I was also wondering how you guys include images in your HTML? I want to have one folder called images and always refer to this folder when I want to use an image. Can anyone explain how I can accomplish these tasks? Thanks a bunch. Quote Link to comment https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/ Share on other sites More sharing options...
DeanWhitehouse Posted December 13, 2008 Share Posted December 13, 2008 I was also wondering how you guys include images in your HTML? I want to have one folder called images and always refer to this folder when I want to use an image. Using the image tags and try doing include($_SERVER['DOCUMENT_ROOT'].'\Classes\Business\register.php'); Quote Link to comment https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/#findComment-714780 Share on other sites More sharing options...
bdicasa Posted December 13, 2008 Author Share Posted December 13, 2008 Thanks for the help. Regarding the image tags, I know how to use the tags, but I was wondering how to always refer to the same folder, regardless of where the file is. I think I know how to do it when rendering HTML with PHP (now that you showed me how to get to the document root), but how would you refer to the same folder if just using a .html file? Quote Link to comment https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/#findComment-714796 Share on other sites More sharing options...
DeanWhitehouse Posted December 14, 2008 Share Posted December 14, 2008 Seriously , go and learn HTML and read up on how to put images into web pages. http://w3schools.com or http://tizag.com You just put the image location to go back one folder do ../image.jpg .../image.jpg = back two folders etc. Quote Link to comment https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/#findComment-714886 Share on other sites More sharing options...
bdicasa Posted December 15, 2008 Author Share Posted December 15, 2008 I know how to use HTML and image tags, thanks. I was more curious as to how web developers always refer to the same folder for their images in HTML REGARDLESS of where the file is (that isn't possible with relative paths because if you move your file you won't be pointing to the right folder anymore). However, I decided to link to my images using the server URL. Quote Link to comment https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/#findComment-715497 Share on other sites More sharing options...
rtadams89 Posted December 15, 2008 Share Posted December 15, 2008 You could always use <a href="http://yourwebsite.com/images/image.jpg" /> Quote Link to comment https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/#findComment-715560 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.