Handling relative paths for include files in PHP
问题 I am doing a project in PHP which I am not very familiar. I am using a MVC framework (CodeIgnitor). I have noticed that each time I return a view that resulted from a longer/shorter url string all of my includes break. It appears that the paths are relative to url. Is $_SERVER["DOCUMENT_ROOT"] the best way to generate include paths in PHP? Thanks! 回答1: base_url() and site_url() is probably what you need. 回答2: You should read the User Guide on URL Helpers. It already has all the infos you need