why this php global doesn't echo in Wordpress plugin -
i'm new php , i'm not sure why doesn't work. have done page said http://php.net/manual/en/language.variables.scope.php (example #1 using global)... why not working? it's frustrating.
this first attempt on wordpress plugins. first file contains:
function pp_sa_menu(){ add_menu_page('shadow accounts search', 'shadow accounts', 'manage_options', 'shadow_accounts', 'pp_sa_search'); } add_action('admin_menu','pp_sa_menu'); function pp_sa_search(){ include('shadow-accounts/admin/sa-admin.php'); }
then sa-admin.php
file problem happens
<?php $sandbox = true; $phost = 'localhost'; $pus = 'user'; $ppas = 'pass'; $pus = 'hello world'; function testfunc(){ global $phost; return $phost; } echo testfunc(); //empty function getforumaccounts(){ global $pus; echo $pus; // empty echo 'test'; // shows 'test' echo $ppas; // empty } getforumaccounts(); ?>
not sure if work different but:
$phost = 'localhost'; function getforumaccounts(){ global $phost; return $phost; } echo getforumaccounts();
function should returning something. in case variable , can echo out or use function in way.
Comments
Post a Comment