From 7c2c57dddc6716ddf94272c5935e8c3e623f3a21 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Wed, 26 Feb 2014 21:23:36 +0000 Subject: [PATCH] Clarify the uniqueness and stability of casting resources to string/integer. It was pointed out on comp.lang.php that the existing wording was unclear on the point of what in the resource->string casting behaviour shouldn't be relied upon (whether it was not guaranteed that the string is unique, or just that the exact format of the string is subject to change). I've also added a paragraph to the integer page noting what a resource->integer cast results in. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332894 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/types/integer.xml | 6 ++++++ language/types/string.xml | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/language/types/integer.xml b/language/types/integer.xml index 1a3416fe9a..8592e14b8e 100644 --- a/language/types/integer.xml +++ b/language/types/integer.xml @@ -197,6 +197,12 @@ var_dump(round(25/7)); // float(4) integer with the intval function. + + If a resource is converted to an integer, then + the result will be the unique resource number assigned to the + resource by PHP at runtime. + + See also Type Juggling. diff --git a/language/types/string.xml b/language/types/string.xml index b303f64949..5a2855cc70 100644 --- a/language/types/string.xml +++ b/language/types/string.xml @@ -960,11 +960,13 @@ bool(false) 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. Do - not rely upon this structure; it is subject to change. To get a - resource's type, use the - get_resource_type function. + 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.