Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Document Path needed if the file is used through alias

Status
Not open for further replies.

evin666

Programmer
Joined
Jun 26, 2003
Messages
5
Location
IN
I am using PHP 4.3.4 with apache 2.

I have a php file in the path :
D:\php_projects\testproject\test.php

Whan I use getcwd() I get the path D:\php_projects\testproject

But I have to put create new files in the folder
D:\php_projects\
and the path is needed as D:/php_projects/

Is there any functions for that.

Thank You.
 
evin666:
Are you asking about the use of backslashes "\" versus forward slashes "/"?

The problem is likely caused by the fact that PHP uses the backslash character as an escape character -- the path "d:\new_files", for example, would contain in PHP the newline ("\n") character, not backslash enn.

Two things to try:

One is to put Win32 filename strings in singlequotes, not doublequotes. In PHP, doublequotes are not interpolated, so 'd:\new_files' will not contain the newline that "d:\new_files" does.

Another is to double up on your backslashes: "d:\\new_files" does not contain the newline, because PHP interprets "\\" as an unescaped backslash.

Otherwise, just use the forward slashes.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank You basteinek.

It worked fine.
I used dirname(getcwd()) for getting the base directory.

Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top