...

View Full Version : folder path in variable



GO ILLINI
06-21-2006, 04:54 AM
...stuff...
$path = 'C:\HLserver\cstrike';
...stuff...
// DO NOT EDIT
$cstrike = $path . '\\';

That is part of my config file for a program I'm making.
Is there any way that the user can just put the path with the \ on the end of it in the $path var? Or is there mayb a way that I could invisibly do the "$cstrike = $path . '\\';"

The one and only,
ILLINI

xconspirisist
06-21-2006, 05:00 AM
Looking for something like this?



if (substr($path, -2) == "\\") {
// nothing
} else if (substr($path, -1) == "\") {
$path = ($path . "\");
} else {
$path = ($path ."\\");
}


That way, $path will always have "\\" on the end.

GO ILLINI
06-21-2006, 05:23 AM
Sorry, I should have said what I wanted $path to turn out to be.
C:\HLserver\cstrike\
Php doesnt like having a \ at the end of a variable, so I had to use the \, to cancle the \. get it?
The code I have to add the final \ works, but I want to know any ideas to hide it somewhere so that the config file is just variables and descriptions.

The one and only,
ILLINI

xconspirisist
06-21-2006, 05:54 AM
You could put this code into another file, and then just do:


require_once("config.php");

But normally a "DO NOT EDIT BELOW THIS LINE" works fine, and most people will understand.

GO ILLINI
06-21-2006, 06:32 AM
ok, Ill just go with the under this line thing.

marek_mar
06-21-2006, 09:26 AM
You could always use forward slashes...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum