3

Is it possible to check this before failing ?

if (is_in_open_basedir($path)) {
}
Maël Nison
  • 7,055
  • 7
  • 46
  • 77
  • This is a good question because I don't think you can do a robust check without using [realpath](http://www.php.net/realpath)(), but realpath() is itself subject to open basedir. – goat Oct 20 '12 at 01:26

3 Answers3

0

You can use ini_get to get the current value of open_basedir to check against the other value.

Aurelia
  • 1,052
  • 6
  • 28
0

I know this does not answer the question exactly, but maybe the motivation behind it:

If you do not need to check before the call and just want to avoid warnings, on functions that access other dirs, another approach would be to use the @ operator and check error_get_last

error_clear_last();
$isDir = @is_dir('/');
if (error_get_last() !== null) {
   $isDir = 'cannot-detect';
}
Alex
  • 32,506
  • 16
  • 106
  • 171
-3

This is not a php standard function. To handle exceptions you can use:

try {

}
catch( $e ) {

}

Check this: PHP Exceptions

Laleft
  • 75
  • 1