php临时目录,PHP: sys_get_temp_dir - Manual

That is important for the purposes of building paths through concatenation to know that sys_get_temp_dir does not include a path separator at the end.

So, sys_get_temp_dir() will return whatever your temp dir is set to, by default:

/tmp

If you attempted to concatenate another dir name  temp and use the following:

mkdir(sys_get_temp_dir() . 'some_dir');

That would actually attempt to generate:

/tmpsome_dir

It would likely result in a permission error unless you are running a php script as a super user.

Instead you would want to do:

mkdir( sys_get_temp_dir() . DIRECTORY_SEPARATOR. 'some_dir' );

which would create:

/tmp/some_dir

I don't know if Windows or other platforms include a directory separator at the end. So if you are writing something a bit more general you may want to check for the path separator at the end and if it is not there append it.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值