SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast digitalbart's Avatar
    Join Date
    Apr 2002
    Location
    chicago
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    include not working from command line in windows

    I am running a script which works in my browser fine but when I try and run it via the command line I get errors:

    saying it failed to open the inclusion path.

    I am running php 5 on my windows box and using the $_SERVER[DOC_ROOT] at the begining of my paths.

    Why will this work in my browser but not when I run it from the command line in windows.
    I have tried typing out the paths and it works but I don't want to search and replace all my code. Is their some environment varaible or any variable that will work?

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHP Manual
    $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server.
    Running php script in browser isn't the same as running it from command line. You're probably better off extracting the path from __FILE__.
    Saul

  3. #3
    SitePoint Enthusiast digitalbart's Avatar
    Join Date
    Apr 2002
    Location
    chicago
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I am not familiar? How would you do that?

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's not that easy if you have a hierarchy of directories. Start at looking up pathinfo.
    Saul

  5. #5
    SitePoint Evangelist AlienDev's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've never worked in with php in windows, but I think the directory seperator is "\\" instead of "/".
    Me on StackOverflow | Blog & personal website.

    I mostly use: PHP, Java, JavaScript, Android.

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Windows supports / as directory separators so its best to use them for compatibility.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

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