Shamoon
Shamoon

Reputation: 43501

How can I get the dir of a php script that's running in CLI?

I have a CLI PHP script and I need to know what directory it's currently running in. Because of some operations, including getcwd(), the directory has changed a bit.

How can I do this?

Upvotes: 1

Views: 49

Answers (2)

pocketfullofcheese
pocketfullofcheese

Reputation: 8837

Perhaps you want: dirname(__FILE__)

http://php.net/manual/en/language.constants.predefined.php

Upvotes: 0

Lumbendil
Lumbendil

Reputation: 2916

You can use the __DIR__ predefined constant.

Upvotes: 2

Related Questions