chdir

(PHP 3, PHP 4, PHP 5)

chdir -- Сменить каталог

Описание

bool chdir ( string directory )

Изменяет текущий каталог PHP на указанный в качестве параметра каталог. Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки..

См.также описание функции getcwd().



chdir
jeprubio _At_ gmail dot com
27-May-2005 12:25
If you run this script when $sym_dir is a symbolic link to a directory:
  echo getcwd()."\n";
  chdir ($sym_dir);
  chdir ('../');
  echo getcwd()."\n";

It returns for example:
  /dades/loc/real/mapes/navteq/anloc
  /mapes/anloc

It will not return to the previous directory, it returns to the parent of the real directory where it links the symbolic link.

It's not necessary a bug but I think it's important to have present this.

It could be solved saving the current directory and then returning to it. For example:
  $cwd = getcwd();
  echo getcwd()."\n";
  chdir ($sym_dir);
  chdir ($cwd);
  echo getcwd()."\n";

It returns:
  /dades/loc/real/mapes/navteq/anloc
  /dades/loc/real/mapes/navteq/anloc

Have fun :)
-------
   Josep Rubio (Anloc S.L. www.anloc.net)

<Каталогиchroot>
 Last updated: Mon, 14 Nov 2005