function method1($data){ // Do something with $data method2($data); } function method2($data){ // Do something with $data }
$data = 'Hello World!'; function method1(){ global $data; // Do something with $data method2(); } function method2(){ global $data; // Do something with $data }
function method1(){ $data = 'Hello World!'; return $data; } function method2(){ $data = method1(); // Do something with $data }
In WP:
function method1($data){ // Do something with $data do_action('my_custom_hook', $data); } function method2($data){ // Do something with $data } add_action('my_custom_hook', 'method2');