-4

Anyone knows alternative function for sys_get_temp_dir and DIRECTORY_SEPARATOR and tempnam in PHP

existing PHP version is 4.*

Mangesh Sathe
  • 1,987
  • 4
  • 21
  • 40

1 Answers1

1

tempnam exists in PHP4

You can use this code from php.net to get a temp dir:

if ( !function_exists('sys_get_temp_dir')) { 
  function sys_get_temp_dir() { 
    if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } 
    if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } 
    if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } 
    $tempfile=tempnam(__FILE__,''); 
    if (file_exists($tempfile)) { 
      unlink($tempfile); 
      return realpath(dirname($tempfile)); 
    } 
    return null; 
  } 
}
castis
  • 8,154
  • 4
  • 41
  • 63
Epharion
  • 1,051
  • 9
  • 20