Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help with windows path - PHP

Tags:

php

I have this path and it is correct however, the browser will not include the source file unless I put "file:///" in front of it. I'm still developing and this will ultimately be on a Linux machine but in the mean time, I'd like to see my work as well as be able to troubleshoot it. Is there a solution for this?

This fails:

C:\Program Files (x86)\work\site\js\rowlock.js

This does not fail:

file:///C:\Program Files (x86)\work\site\js\rowlock.js
like image 573
jim Avatar asked Feb 25 '10 14:02

jim


2 Answers

just use front slashes everywhere if you'll be moving this to a linux box anyway. php for windows can understand it.

$file='c:/Program Files (x86)/work/site/js/rowlock.js';
like image 196
bcosca Avatar answered Sep 27 '22 16:09

bcosca


Try using variable $_SERVER['DOCUMENT_ROOT'] to make your script independent. For example:

include($_SERVER['DOCUMENT_ROOT'].'/js/rowlock.js');

Works fine on any system

like image 21
Silver Light Avatar answered Sep 27 '22 16:09

Silver Light