PHP sys_get_temp_dir() Function
Last Updated :
22 Mar, 2023
The sys_get_temp_dir() is an inbuilt function where the directory path for temporary files will be returned.
Syntax:
sys_get_temp_dir()
Parameter: This function doesn’t accept any parameter.
Return Value: This function returns the path for the temporary directory.
Example 1: This code demonstrates the sys_get_temp_dir() function.
PHP
<?php
echo sys_get_temp_dir();
?>
|
Output:
/tmp
Example 2: This is another code that demonstrates the sys_get_temp_dir() function.
PHP
<?php
$temp_file = tempnam(sys_get_temp_dir(), 'gfg' );
echo $temp_file ;
?>
|
Output:
/tmp/gfgluzYqw
Reference: https://www.php.net/manual/en/function.sys-get-temp-dir.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...