FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Correlating curl resources to some other object.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Correlating curl resources to some other object. [message #185109 is a reply to message #185108] Wed, 26 February 2014 21:48 Go to previous messageGo to previous message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma:
Member
On 2/26/14 1:25 PM, Adam Harvey wrote:
> On Wed, 26 Feb 2014 13:52:10 -0500, Jerry Stuckle wrote:
>> On 2/26/2014 12:52 PM, Daniel Pitts wrote:
>>> On 2/26/14 9:07 AM, Jerry Stuckle wrote:
>>>> I don't think there is a guarantee that casting a resource to a string
>>>> results in a unique string (although it does seem to work this way
>>>> currently).
>>> The documentation *does* say it is a unique string.
>>>
>>> 'Resources are always converted to strings with the structure "Resource
>>> id #1", where 1 is the unique number assigned to the resource by PHP at
>>> runtime'
>>>
>>>
>> That could be read two ways. For instance, if a resource is destroyed,
>> creating a new resource could have the same number. It would still
>> identify a unique *valid* resource.
>
> To be clear: resource numbers aren't reused within an individual request.
> (At present, they always increase sequentially -- I don't see that
> changing, but also wouldn't want to guarantee it.)
>
>>> Of course, it then says don't rely on that structure. Grr.
>>>
>>>
>> Yes, as I said, I agree it seems to always be a unique value (it
>> increments one for each resource created). But nothing says it will
>> remain so, and the doc seems to indicate the opposite.
>>
>> Of course, it could also mean don't rely in it being exactly "Resource
>> id #1" - but later could be something like "curl resource #1", "mysql
>> resource #2", or even just "curl 1" - but still unique.
>
> That's the intention. I agree it was poorly worded.
>
>> The doc is not
>> at all clear on this. I would like to see a clarification on this
>> point, for just the reasons you've stated.
>
> I've committed an update to the manual to clarify this. The new wording
> (which will appear over the weekend, assuming no issues with the
> documentation build on Friday) is:
>
> Resources are always converted to strings with the structure "Resource id
> #1", where 1 is the resource number assigned to the resource by PHP at
> runtime. While the exact structure of this string should not be relied on
> and is subject to change, it will always be unique for a given resource
> within the lifetime of a script being executed (ie a Web request or CLI
> process) and won't be reused. To get a resource's type, use the
> get_resource_type() function.
>
>>> I wonder if a feature request to support an "spl_resource_hash" would
>>> get any traction.
>>>
>> I would support some kind of truly unique identifier which could be used
>> as a key. Whether it is an spl_resource_hash or something else makes
>> little difference, as long as it's useful.
>
> As noted above, the intention is that casting a resource to a string
> should result in a unique identifier, so a function is unnecessary in
> this case.
Awesome! Thanks for that.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Why is polymorphism in PHP not like other languages? Is there a bug in PHP?
Next Topic: Operator precedence
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 19:45:47 GMT 2024

Total time taken to generate the page: 0.08365 seconds