note 111198 added to function.tmpfile
| From: | dzhax | Date: | Thu, 24 Jan 2013 23:34:23 +0000 |
| Subject: | note 111198 added to function.tmpfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193379@lists.php.net to get a copy of this message | ||
> $tmp=array_search('uri',
> @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));
why do you store file handler in $GLOBALS with a random key, if you will not use it?
why do you flip an array and search it's key by value, if you can simply get value by key?
this is totally wrong.
> $meta = stream_get_meta_data(tmpfile());
> $tmp = $meta['uri'];
this is a way better!!
or
> $tmp = stream_get_meta_data(tmpfile())['uri'];
since php 5.4.
----
Server IP: 69.147.83.199
Probable Submitter: 81.198.143.143
----
Manual Page -- http://php.net/manual/en/function.tmpfile.php
Edit -- https://master.php.net/note/edit/111198
Del: integrated -- https://master.php.net/note/delete/111198/integrated
Del: useless -- https://master.php.net/note/delete/111198/useless
Del: bad code -- https://master.php.net/note/delete/111198/bad+code
Del: spam -- https://master.php.net/note/delete/111198/spam
Del: non-english -- https://master.php.net/note/delete/111198/non-english
Del: in docs -- https://master.php.net/note/delete/111198/in+docs
Del: other reasons-- https://master.php.net/note/delete/111198
Reject -- https://master.php.net/note/reject/111198
Search -- https://master.php.net/manage/user-notes.php