Relative URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Relative URL (/showthread.php?tid=60908) |
Relative URL - El Forum - 07-28-2014 [eluser]Unknown[/eluser] I have an include_once statement in a view that is not working. Is there any specific way to use relative URLs and navigate in the directory tree, when using CodeIgniter? This is my include statement: include("/../../models/classes1/classes2/classetouse.php"); I get the following error message: A PHP Error was encountered Severity: Warning Message: include(/../../models/classes1/classes2/classetouse.php) [function.include]: failed to open stream: No such file or directory Filename: views/checkyouremail.php Line Number: 3 A PHP Error was encountered Severity: Warning Message: include() [function.include]: Failed opening '/../../models/classes1/classes2/classetouse.php' for inclusion (include_path='.:/opt/alt/php53/usr/share/php:/opt/alt/php53/usr/share/pear') Filename: views/checkyouremail.php Line Number: 3 Can you please help? My thanks in advanced Relative URL - El Forum - 07-28-2014 [eluser]CroNiX[/eluser] Everything is relative to INDEX.PHP, since that's actually the file being executed by PHP. Starting a path with a / isn't really "relative", it's the root of the device (usually a hard disk). But if you're loading a model, why not just use $this->load->model('classes1/classes2/classtouse.php') ?? You also can use the APPPATH constant defined at the bottom of index.php (along with others), which is the full path to the /application directory, but I prefer just using the built in CI loader class which works for 99% of things. |