php - Reuse instance of class -


i thinking missing out on oop php.

i developing plugin wordpress have class declaration book:

<?php class wpbook{     private $title;     function settitle($_title){         $this->title = $_title;     }     function gettitle(){         return $this->title;     } } ?>  add_action( 'hookone', 'function_do_stuff'); add_action( 'hookafter_hookone', 'function_do_more_stuff'); function function_do_stuff(){      //some more stuff     $newbook = new wpbook;     $title = $newbook->settitle ='titlea';     echo $title; //echos 'titlea';     // function_do_more_stuff($title); not work because     // function called on hookafter_hookone }  function function_do_more_stuff(){     // here want access $title function_do_stuff();     // not know how. } 

now want able access title of book do_stuff() function function do_more_stuff().

the problem can't use returns form do_stuff() do_more_stuff(), because do_more_stuff() called on action-hook.

so problem not know how access title of same product 2 different functions passing 1 variable 1 function function.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -