Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts

    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

  • #2
    Regular Coder xconspirisist's Avatar
    Join Date
    Jun 2006
    Location
    Great Britain.
    Posts
    138
    Thanks
    1
    Thanked 6 Times in 6 Posts
    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.

  • #3
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    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

  • #4
    Regular Coder xconspirisist's Avatar
    Join Date
    Jun 2006
    Location
    Great Britain.
    Posts
    138
    Thanks
    1
    Thanked 6 Times in 6 Posts
    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.

  • #5
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    ok, Ill just go with the under this line thing.
    Why not thank me?

    http://adamsworld.name

  • #6
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •