note 124779 added to function.sys-get-temp-dir

From: Date: Mon, 02 Mar 2020 01:28:06 +0000
Subject: note 124779 added to function.sys-get-temp-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-214266@lists.php.net to get a copy of this message
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. ---- Server IP: 45.112.84.4 Probable Submitter: 38.142.137.34 (proxied: 2601:647:8400:fb60:61ce:e017:704f:96df) ---- Manual Page -- http://php.net/manual/en/function.sys-get-temp-dir.php Edit -- https://master.php.net/note/edit/124779 Del: integrated -- https://master.php.net/note/delete/124779/integrated Del: useless -- https://master.php.net/note/delete/124779/useless Del: bad code -- https://master.php.net/note/delete/124779/bad+code Del: spam -- https://master.php.net/note/delete/124779/spam Del: non-english -- https://master.php.net/note/delete/124779/non-english Del: in docs -- https://master.php.net/note/delete/124779/in+docs Del: other reasons-- https://master.php.net/note/delete/124779 Reject -- https://master.php.net/note/reject/124779 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214266) next »