跳转到主要内容

WP_CLI\Utils\make_temp_file()

Create a unique temporary file safely without following symlinks.


Usage

WP_CLI\Utils\make_temp_file( $prefix = wp-cli-, $suffix = '' )
$prefix (string) Optional. Prefix for the temporary file name. Default 'wp-cli-'.
$suffix (string) Optional. Suffix for the temporary file name. Default ''.
@return (string) to the created temporary file.

Notes

The file is only readable and writable by its owner on non-Windows systems.

The file is created in the directory returned by WP-CLI's get_temp_dir() (based on sys_get_temp_dir()), not WordPress's get_temp_dir(), and is not removed automatically; callers are responsible for cleaning it up.

On failure, this function exits via WP_CLI::error() rather than throwing.

Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.