How to preserve path structure with PHP include?

You can either use an absolute path, eg or, if you want to keep it portable, set a dynamic for relative paths. This way you can move your entire app to a sub-directory without breaking reference links, eg.

I'm currently using localhost. How would I use localhost as my base? I tried ; but it didn't work – Arnold Porche Villaluz Aug 1 at 6:37 @Arnold Don't forget the trailing slash.

Try . I've updated my answer to match your environment better – Phil Aug 1 at 6:38 this one works, adding the extra "/" at the end was the issue. Thank so you much!

– Arnold Porche Villaluz Aug 1 at 6:43.

You have multiple options to get the desired result: You can define a prefix variable/constant at the top of every page which you then use in all your includes/urls/etc. You can also use the tag in your header pointing to the absolute URL to ../ so something like ys.cc/proj/ if your forms directory is ys.cc/proj/forms.

Phil You're right, fixed it. Thanks – Tarek Fadel Aug 1 at 6:39.

You can write your css file selector from: css/file. Css to /css/file. Css This will work in all folders.

I tried that, but it didnt' work :( – Arnold Porche Villaluz Aug 1 at 6:32 @arnold-porche-villaluz The difference between those two is guaranteed behavior. If that didn't work, there's something wrong. – Christian Sciberras Aug 1 at 6:38 @Christian The OP confused us by saying the css directory was in the "root" directory.

Looks like it's actually in a mySite sub-directory – Phil Aug 1 at 6:42.

You can also save a constant of you application path and use it like this $app = "example.com"; include($app. "css/file. Css").

CSS files are generally included using the tag – Phil Aug 1 at 6:52 ohh yes sorry for the include code – Sumair Zafar Aug 1 at 9:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions