w3resource

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:


<?php
$file_hand =fopen("text.txt","w");
echo get_resource_type($file_hand);
?>

Output:

stream

Practice here online :

See also

PHP Function Reference

Previous: get_defined_vars
Next: gettype



PHP: Tips of the Day

Returns true if the given string is a palindrome, false otherwise

Example:

<?php
function tips_palindrome($string)
{
  return strrev($string) === (string) $string;
}

print(tips_palindrome('malayalam'));
print("\n");
print(tips_palindrome(151));

?>

Output:

1
1