Jump to content

What is the meaning of Resouce ID?


shah_ankitb

Recommended Posts

I have searched about that & i will find 'Resource IDs are "file pointers" basically. The data from a MySQL lookup is stored in memory, and Resource ID tells PHP where to find it.' I am not satisfied with this answer.Can Anobody explain it more deeply if possible with example?What is the exact meaning of Resouce Id.

Link to comment
Share on other sites

PHP keeps a list of resources that have been created. Resources include things like database connections, file handles, etc, that are neither objects nor scalar data like strings or numbers. The resource ID for any given resource is just a number that PHP uses to tell it which resource in the list of resources you are using. It's not useful for a program to look at or save a resource ID, you can't do anything with it. It's just an internal reference for use by PHP. If that doesn't explain it to your liking, what do you want to know about it? There's very little, if anything, that you need to know about it.

Link to comment
Share on other sites

Thanx for Reply, When i run query, sometimes it is displaying as output 'Resorce IDd #23'.So on which basis this Number is generated or It randomly allocated or it based on Query u r firing.If u can explain with example then it wil be more useful as i think.

Link to comment
Share on other sites

I got it from 'PHP Manual' In the Index Searching with 'Resource' and 'Resources'. It is similar that what u r saying but they have explained more deeply, may be this can help u also .If u don't find that, then i can copy/paste whole content for u.

Link to comment
Share on other sites

It's based on how many resources have already been created. If you have a script and you have a ton of file handles open, and connections to other servers and whatever, then the resource ID for a new resource will be higher. If you create a script, create a single resource, and print out the ID then it will be smaller. I believe that PHP loads certain resources for itself (libraries, etc) so that you may not be able to have a resource ID #1, but I don't know, you may. I've never done any research about how they get allocated. Essentially, a new resource gets the next ID that is available. The fact that you are seeing the resource ID printed is because you are trying to print the resource. A resource is not a printable object, so when you try to print the resource instead it just prints the resource ID. The same way that if you try to print an array, it will just print the word "array".

Link to comment
Share on other sites

It means It depends on ur application & PHP which generates Resource ID's.If my application is small then it will generate Lower Resource ID else Higher Resouce ID. Does it like that?. Tell me everything (if) u know more about Resouce ID.Elaborate it more deeply as u can that will help me to understand more.

Link to comment
Share on other sites

There isn't really anything to understand, that's what I'm trying to get across. PHP will assign resource IDs to resources, but your application does not need to use the resource IDs or even look at them for anything, your application cannot do anything with them. If you want to test if lower or higher resource IDs get created, then create a test script that creates various resources and see what happens. But there's nothing you need to know about resource IDs, they aren't significant to the programmer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...