Path to php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Csaba Gabor

    #1

    Path to php

    Is there any way (on Windows) to determine, from within php, the
    directory that it is running from? In other words, what is the path to
    PHP? This particularly concerns the CLI php versions. On Linux, it
    has been suggested to do:
    which php
    but even this wouldn't help me since that would just show A php on the
    include path and not necessarily the currently executing instance.

    Also, getcwd() at startup only shows the path that php was started from
    and __FILE__ and phpinfo() do not offer this info either.

    Thanks,
    Csaba Gabor from Vienna

  • Mike Willbanks

    #2
    Re: Path to php

    Csaba,[color=blue]
    > Is there any way (on Windows) to determine, from within php, the
    > directory that it is running from? In other words, what is the path to
    > PHP? This particularly concerns the CLI php versions. On Linux, it
    > has been suggested to do:
    > which php
    > but even this wouldn't help me since that would just show A php on the
    > include path and not necessarily the currently executing instance.[/color]


    The $_ENV["ORIG_SCRIPT_FI LENAME"] if that variable exists for you...
    Another way is if your extension dir is right off of the php root you
    could simply back pedal from the extension dir setting :)

    Mike

    Comment

    • Csaba Gabor

      #3
      Re: Path to php

      Mike Willbanks wrote:[color=blue]
      > Csaba Gabor wrote:[color=green]
      > > Is there any way (on Windows) to determine, from within php, the
      > > directory that it is running from? In other words, what is the path to
      > > PHP? This particularly concerns the CLI php versions. On Linux, it[/color]
      >
      > The $_ENV["ORIG_SCRIPT_FI LENAME"] if that variable exists for you...
      > Another way is if your extension dir is right off of the php root you
      > could simply back pedal from the extension dir setting :)[/color]

      Hi Mike, thanks for your response, but that determines the PHP script
      that is running and not the PHP.exe (or php-win.exe or whatever) that
      is running it. I'm after the executable location - not the script
      location.

      Csaba

      Comment

      Working...