note 111198 rejected from function.tmpfile by aharvey
| From: | aharvey@php.net | Date: | Fri, 25 Jan 2013 01:15:51 +0000 |
| Subject: | note 111198 rejected from function.tmpfile by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193382@lists.php.net to get a copy of this message | ||
Note Submitter: dzhax
----
> $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.