Advertisement
arvind_iyer_2001

Untitled

Nov 16th, 2023
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. class TextClass{
  4.  
  5.     function __construct(){
  6.         $file_contents = file_get_contents("file.txt");
  7.         print $file_contents;
  8.     }
  9. }
  10.  
  11. class HelperClass{
  12.  
  13.     public $file = "file.txt";
  14.  
  15.     function load_data($data){
  16.         file_put_contents($this->file, $data);
  17.     }
  18. }
  19.  
  20. class MainClass{
  21.  
  22.     public $obj;
  23.     public $data;
  24.  
  25.     function __construct($data) {
  26.         $this->data = $data;
  27.     }
  28.  
  29.     function __wakeup(){
  30.         if(isset($this->obj)){
  31.             $this->obj->load_data($this->data);
  32.         }
  33.     }
  34.  
  35.  
  36. $o = new MainClass("");
  37. echo serialize($o);
  38.    
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement