PHP get resource type

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : get_resource_type() function

Description

The get_resource_type() function returns the resource type.

Version

(PHP 4 and above)

Syntax

get_resource_type(file_handle)

Parameter

Name

Description

Required /
Optional

Type

file_handle

When a file is successfully opened by fopen() or fsockopen() it returns a resource ID, which is referred as file handler or file pointer

Required

Resource

 

Return value

If the given file_handle is a resource, this function will return a string representing its type.

Value Type : String.

Example :

  1. $file_hand =fopen("text.txt","w");  

  2. echo get_resource_type($file_hand);  

  3. ?>  

Output :

stream