(Php 5> = 5.2.1, Php 7, Php 8)
SYS_GET_TEMP_DIR - Trả về đường dẫn thư mục được sử dụng cho các tệp tạm thời — Returns directory path used for temporary files
Sự mô tả
sys_get_temp_dir (): chuỗi(): string
Thông số
Chức năng này không có tham số.
Trả về giá trị
Trả về đường dẫn của thư mục tạm thời.
Ví dụ
Ví dụ #1 sys_get_temp_dir () ví dụsys_get_temp_dir() example
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
echo
$temp_file;
?>
Ví dụ trên sẽ xuất ra một cái gì đó tương tự như:
C:\Windows\Temp\TuxA318.tmp
Xem thêm
- tmpfile () - tạo một tệp tạm thời
- Tempnam () - Tạo tệp có tên tệp duy nhất
Osakawebbie ¶ ¶
5 năm trước
If running on a Linux system where systemd has PrivateTmp=true (which is the default on CentOS 7 and perhaps other newer distros), this function will simply return "/tmp", not the true, much longer, somewhat dynamic path.
Royanee tại Yahoo Dot Com ¶ ¶
8 năm trước
As of PHP 5.5.0, you can set the sys_temp_dir INI setting so that this function will return a useful value when the default temporary directory is not an option.
Ẩn danh ¶ ¶
14 năm trước
This function does not always add trailing slash. This behaviour is inconsistent across systems, so you have keep an eye on it.
Ẩn danh ¶ ¶
14 năm trước
it should be mentioned that the return value of sys_get_temp_dir() can be set using the ini-directive 'sys_temp_dir' globally as well as per directory by using
php_admin_value sys_temp_dir /path/to/tmp
7 năm trước ¶
14 năm trước
A very helpful thing to note when on Linux:
If you are running PHP from the commandline you can use the environment variable: TMPDIR - to change the location without touching php.ini. - This should work on most versions of PHP.
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
0
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
1
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
2
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
3 7 năm trước ¶
Nimja ¶
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
4
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
5
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
6
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
3 Bert-Jan tại Bugbyte Dot NL ¶ ¶
12 năm trước
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
8
OHCC tại 163 dot com ¶ ¶
6 năm trước
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
9
echo
0
echo
1
echo
2
echo
3
echo
4
echo
5
echo
6
echo
7
echo
8
<?php
// Create a temporary file in the temporary
// files directory using sys_get_temp_dir()
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
3
Ẩn danh ¶ ¶
14 năm trước
$temp_file;
?>
0