Where have all the slashes gone?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Where have all the slashes gone?

Post by Wolf_22 »

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?
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Re: Where have all the slashes gone?

Post by Wolf_22 »

Sorry everyone... It turned out that this was more of a PHP issue as I discovered that "addslashes()" did the trick. Now I just need to turn the "C:\" into "http://localhost". Anyone have any advice on this?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Where have all the slashes gone?

Post by daedalus__ »

what are you doing ? why do you need an absolute path?
Post Reply