Boston Linux & UNIX was originally founded in 1994 as part of The Boston Computer Society. We meet on the third Wednesday of each month at the Massachusetts Institute of Technology, in Building E51.

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] php question. change directory to executing script.



Hi All,

I have a little function that needs to delete some files.  I don't want it to delete them from the directory of my user, but in the directory of the script.

For example from terminal:

cd $HOME
php /path/to/script/foo.php  // will execute foo in home

But I want it to execute foo in /script.

So in the function I told it to change working directory to script path.

chdir(dirname(__FILE__));

Am I missing something or is this OK?  Is it evil to do such a thing?

Thanks,
Eric Chadbourne



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org