soltek Posted September 15, 2012 Share Posted September 15, 2012 Hey guys, I'm trying to customize the look of a script, but I'm having issues extracting the output of a string - I think that's a string. This is the the code the function/string: function notice(){ printf($this->lang['notice'],Tools_get::convert_time($this->ttl*60),$this->limitPERIP,Tools_get::convert_time($this->ttl_ip*60)); $this->CheckMBIP(); $MB1IP = Tools_get::convertmb($this->countMBIP*1024*1024); $thislimitMBIP = Tools_get::convertmb($this->limitMBIP*1024*1024); $maxsize = Tools_get::convertmb($this->max_size_other_host*1024*1024); printf($this->lang['yourjobs'],$_SERVER['REMOTE_ADDR'],$this->lookup_ip($_SERVER['REMOTE_ADDR']),$this->max_jobs_per_ip,$MB1IP,$thislimitMBIP); printf($this->lang['status'],$maxsize,count($this->jobs),$this->max_jobs,$this->get_load(),$this->max_load,Tools_get::useronline()); } And this is the code on the footer that display the IP address, maximum jobs and stuff: <?php echo $obj->notice();?> This last line prints everything I need on the page, but I wanted to put them inside <span>s, to I tried to do something like: <span><?php echo <?php echo $config->lang['yourjobs'] ?></span> But it doesn't work. Can you give me hand please? Link to comment https://forums.phpfreaks.com/topic/268413-extracting-data-from-string-i-guess/ Share on other sites More sharing options...
Barand Posted September 15, 2012 Share Posted September 15, 2012 You are trying to echo the result of a function (notice() ) that doesn't return anything. Change the printf()s to sprintf()s. function notice() { $result = ''; $result .= sprintf(....); ... $result .= sprintf(...); return $result; } Link to comment https://forums.phpfreaks.com/topic/268413-extracting-data-from-string-i-guess/#findComment-1378249 Share on other sites More sharing options...
ManiacDan Posted September 16, 2012 Share Posted September 16, 2012 Better yet, put your <span> tags right in the notice() function: printf($this->lang['notice'],Tools_get::convert_time($this->ttl*60),$this->limitPERIP,Tools_get::convert_time($this->ttl_ip*60)); Becomes: printf('<span>' . $this->lang['notice'] . '</span>',Tools_get::convert_time($this->ttl*60),$this->limitPERIP,Tools_get::convert_time($this->ttl_ip*60)); Link to comment https://forums.phpfreaks.com/topic/268413-extracting-data-from-string-i-guess/#findComment-1378288 Share on other sites More sharing options...
Christian F. Posted September 16, 2012 Share Posted September 16, 2012 You really should take a second look at the last line of code you posted too, and turn on error handling: You have quite a few errors in that bit, and it shows a lack of understanding on how PHP actually works. Either that, or it's a copy-pasta error, and you didn't pay enough attention to your code. Link to comment https://forums.phpfreaks.com/topic/268413-extracting-data-from-string-i-guess/#findComment-1378303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.