downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

NULL> <オブジェクト
[edit] Last updated: Fri, 17 May 2013

view this page in

リソース

リソースは特別な変数であり、外部リソースへのリファレンスを保持しています。 います。リソースは、特別な関数により作成され、使用されます。 これらの関数および対応する全てのリソース型の一覧については、 付録 を参照ください。

get_resource_type() も参照ください。

リソースへの変換

リソース型は、オープンされたファイル、データベース接続、 イメージキャンバスエリアのような特殊なハンドルを保持するため、 他の値をリソースに変換することはできません。

リソースの開放

PHP 4 の Zend エンジンに導入されたリファレンスカウンティングシステムのおかげで、 あるリソースがもう参照されなくなった場合に (Java と全く同様に)、 そのリソースは自動的に削除されます。この場合、このリソースが作成した 全てのリソースは、ガベージコレクタにより開放されます。 このため、free_result 関数を用いて手動でメモリを開放する必要が生じるのはまれです。

注意: 持続的データベース接続は特別で、ガベージコレクタにより破棄されません。 持続的接続 も参照ください。



add a note add a note User Contributed Notes リソース - [1 notes]
up
0
adrian dot dziubek at gmail dot com
4 years ago
I spent an hour trying to create mock setup for testing SQL queries. The explanation here, that a resource contains file handlers and therefore there is no sense in trying to create one is lame. Being unable to redefine functions, creating a fake resource was the second thing I tried to put test in place, but looking at the search results, I see I'm the first one to try... For me it looks like security by obscurity.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites