Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/136862-solved-using-include-and-image-urls/
Share on other sites

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');

 

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?

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.

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.

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.