Utherr12 Posted April 9, 2011 Share Posted April 9, 2011 include_once '../../../../inc/init.php';require_once '../lang/'.$conf['lang'].'/lang.php';echo $lang['name']; //this works and display 'Name: 'if(!isset($_REQUEST['action'])) exit(0);$ACTION = $_REQUEST['action'];switch ($ACTION) { case 'get_info': { --something-- break; } case 'search': { $search_string = trim(strip_tags($_REQUEST['string'])); $sort = $_REQUEST['sortBy']; $values = ""; //$xml is from SimpleXMLElement $json = json_encode($xml); $json_d = json_decode($json,true); $x = JSONtoHTML($json_d); echo $x; break; }}function JSONtoHTML($json){ $html = ""; $tags = ""; if(empty($json)) return 0; foreach($json['plugin'] as $plugin) { $html .= '<span name="plugin_search" p_name="'.$plugin['id'].'" p_author="'.$plugin['author'].'" p_type="'.$plugin['type'].'">'; $html .= ' <p><h4>'.$lang['name'].$plugin['name'].'</h4></p>'; $html .= ' <p><b>'.$lang['author'].'</b>'.$plugin['author'].'</p>'; $html .= ' <p><b>'.$lang['type'].'</b>'.$plugin['type'].'</p>'; $html .= ' <p><b>'.$lang['last_update'].'</b>'.$plugn['lastupdate'].'</p>'; $html .= ' <p><b>'.$lang['description'].'</b>'.$plugin['description'].'</p>'; foreach($plugin['tags'] as $tag) $tags .= $tag." "; $html .= ' <p><b>'.$lang['tags'].'</b>'.$tags.'</p>'; $html .= ' <input class="button" type="button" value="'.$lang['btn_download'].'" /><hr />'; $html .= '</span>'; $tags = ""; } return $html;}// the function works, except that $lang[''] is not displayed anywhere Help? (again) $lang array is taken from lang.php Link to comment Share on other sites More sharing options...
justsomeguy Posted April 10, 2011 Share Posted April 10, 2011 The $lang variable needs to be global in the function, it's looking for a local $lang variable because you haven't marked it as global. Link to comment Share on other sites More sharing options...
Utherr12 Posted April 11, 2011 Author Share Posted April 11, 2011 Thanks, I solved the problem, I hate how PHP handles global variables. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.