System::mktemp – Create temporary files or directories


require_once "System.php";

mixed System::mktemp ( string $args = null )


Creates temporary files or directories. This function will remove the created files when the scripts finish its execution.


  • string $args - The arguments

    • prefix - The string that will be prepended to the temp name (defaults to tmp)

    • -d - A temporary dir will be created instead of a file.

    • -t - The target dir where the temporary file or directory will be created. If this parameter is missing, by default the environment vars TMP on Windows or TMPDIR on Unix will be used. If these vars are also missing c:\windows\temp or /tmp will be used.

Return value

mixed - the full path of the created file or dir, or FALSE


This function can be called statically.


Using mktemp()

$tempdir  System::mktemp("-d prefix");
$tempfile System::mktemp();
$tempfile System::mktemp("-t /var/tmp prefix");
concatenate files (Previous) Get path of temporal directory (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.