Where have all the slashes gone?
Posted: Mon Dec 28, 2009 9:10 pm
I have a PHP constant containing the root path of my website. So if it's on my WAMP server, it would be in the form of "C:\WWW\..." whereas having it on an actual production server would cause it to be in the form of "http://www.example.com/". I need to be able to use this value for a JavaScript variable. I've passed the variable to the JavaScript function perfectly fine, but when it comes out, it's structure is wrong which means that the directory URL this value represents is also wrong.
Keeping that in mind, it's coming out like this: "C:WWWwebsitesweb_11_test/resources/themes/default/c/" when displayed via "alert()".
The only thing I did with this constant is take it from it's original definition and copy it (assign it) to a JavaScript variable to be used in that JavaScript function I mentioned. Otherwise, it has been kept in its original form--I have not used it with any regex or other functions and I have not prepended / appended anything to it at all.
Why are the slashes being dropped? If I can get them back and get the URL to output like it needs to, then will they cause problems when they inevitably come back as backward slashes if on my laptop, also?
Keeping that in mind, it's coming out like this: "C:WWWwebsitesweb_11_test/resources/themes/default/c/" when displayed via "alert()".
The only thing I did with this constant is take it from it's original definition and copy it (assign it) to a JavaScript variable to be used in that JavaScript function I mentioned. Otherwise, it has been kept in its original form--I have not used it with any regex or other functions and I have not prepended / appended anything to it at all.
Why are the slashes being dropped? If I can get them back and get the URL to output like it needs to, then will they cause problems when they inevitably come back as backward slashes if on my laptop, also?