PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   PHP Resource Type Extension   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example script
Class: PHP Resource Type Extension
Extend PHP resource values to save and load values
Author: By
Last change:
Date: 5 years ago
Size: 1,891 bytes
 

Contents

Class file image Download
<?php
require_once('Extended_resource.class.php');

echo
'<pre>';
$x=new resource('fopen("'.str_replace("\\","/",__FILE__).'","rb+")');
$x->dump();

echo
'<br>';
echo
'<br>';

$x->export();
echo
'<br>';
echo
'<br>';

print_r($x);
echo
'<br>';
echo
'<br>';

var_dump(
$x->type(),
ftell($x->use_resource())
);


fseek($x->use_resource(),98);

$u=$x->use_resource();
echo
'<br>';
echo
'<br>';
var_dump(ftell($u));
echo
'<br>';
echo
'<br>';

var_dump($y=serialize($x));
echo
'<br>';
echo
'<br>';

var_dump(unserialize($y));
echo
'<br>';
echo
'<br>';

try{
   
resource();
}catch (
Exception $e) {
    echo
'Exception : ', $e->getMessage(), "\n";
}
echo
'<br>';
echo
'<br>';

$u=var_export(unserialize($y),true);
echo
'<br>';
echo
'<br>';

eval(
'$t = '.$u.';');

var_dump($t);


var_dump(clone($t));

class
test{
    public
$property,$position=null;
   
    public function
__construct(){
       
$this->property=resource('fopen("'.str_replace("\\","/",__FILE__).'","rb+")');
       
    }
   
    public function
seek($position,$whence=false){
       
fseek($this->property->use_resource(),$position,$whence);
       
$this->position=$position;
    }
   
   
    public function
gets($length=null){
        if(
is_int($length)) $line=fgets($this->property->use_resource(),$length);
        else
$line=fgets($this->property->use_resource());
       
$this->position=ftell($this->property->use_resource());
        return
$line;
           
    }
   
    public function
tell(){
        return
$this->position;
    }
                       
    public function
__wakeup(){
       
$this->seek($this->position);
    }
                   
                   
}

$test= new test();

var_dump($test);
$content='';
while(
$line=$test->gets()){
   
$content.=$line;
   
var_dump($test->tell());
}

highlight_string($content);

$test2=serialize($test);
echo
'<br>';
echo
'<br>';

print_r($test2=unserialize($test2));
echo
'<br>';
echo
'<br>';
var_dump($test2->tell());


?>