PHP Tutorial Tutorials - PHP Resource Data Type

PHP Resource Data Type

A resource is a special variable, holding a reference to an external resource.
Resource variables typically hold special handles to opened files, database connections, FTP connections, image canvas areas and the like.

<?php  
    $conn = ftp_connect("127.0.0.1") or die("Could not connect");
    var_dump($conn);
    echo get_resource_type($conn).PHP_EOL;  
    
    $fp = fopen("foo", "w");
    var_dump($fp);
    echo get_resource_type($fp).PHP_EOL;
?>
resource(2) of type (FTP Buffer)
FTP Buffer
resource(4) of type (stream)
stream

Date:2019-10-01 01:02:49 From:www.Lautturi.com author:Lautturi