Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2006, 03:54 AM   PM User | #1
GO ILLINI
Regular Coder

 
GO ILLINI's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 634
Thanks: 0
Thanked 7 Times in 7 Posts
GO ILLINI is an unknown quantity at this point
folder path in variable

PHP Code:
...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
__________________
Why not thank me?

http://adamsworld.name
GO ILLINI is offline   Reply With Quote
Old 06-21-2006, 04:00 AM   PM User | #2
xconspirisist
Regular Coder

 
xconspirisist's Avatar
 
Join Date: Jun 2006
Location: Great Britain.
Posts: 137
Thanks: 1
Thanked 6 Times in 6 Posts
xconspirisist has a little shameless behaviour in the past
Looking for something like this?

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

That way, $path will always have "\\" on the end.
xconspirisist is offline   Reply With Quote
Old 06-21-2006, 04:23 AM   PM User | #3
GO ILLINI
Regular Coder

 
GO ILLINI's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 634
Thanks: 0
Thanked 7 Times in 7 Posts
GO ILLINI is an unknown quantity at this point
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
__________________
Why not thank me?

http://adamsworld.name
GO ILLINI is offline   Reply With Quote
Old 06-21-2006, 04:54 AM   PM User | #4
xconspirisist
Regular Coder

 
xconspirisist's Avatar
 
Join Date: Jun 2006
Location: Great Britain.
Posts: 137
Thanks: 1
Thanked 6 Times in 6 Posts
xconspirisist has a little shameless behaviour in the past
You could put this code into another file, and then just do:

PHP Code:
require_once("config.php"); 
But normally a "DO NOT EDIT BELOW THIS LINE" works fine, and most people will understand.
xconspirisist is offline   Reply With Quote
Old 06-21-2006, 05:32 AM   PM User | #5
GO ILLINI
Regular Coder

 
GO ILLINI's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 634
Thanks: 0
Thanked 7 Times in 7 Posts
GO ILLINI is an unknown quantity at this point
ok, Ill just go with the under this line thing.
__________________
Why not thank me?

http://adamsworld.name
GO ILLINI is offline   Reply With Quote
Old 06-21-2006, 08:26 AM   PM User | #6
marek_mar
Sensei


 
Join Date: Aug 2003
Location: One step ahead of you.
Posts: 2,815
Thanks: 0
Thanked 3 Times in 3 Posts
marek_mar is on a distinguished road
You could always use forward slashes...
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.

Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.
marek_mar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:02 PM.


Advertisement
Log in to turn off these ads.