newbtophp Posted August 31, 2009 Share Posted August 31, 2009 I have a function which is below, but the $sitename is not working, the variable is filled in the included file though. Can anyone tell me what im doing wrong? <?php include("service.php"); echo $num; $t = new Klient; $t->debug=true; $t->onLogin="change_nick"; $t->init("$account","$password"); $t->login(); $t->main(); $t->quit(); function change_nick(){ global $t; $t->setNick('$sitename'); } ?> Link to comment https://forums.phpfreaks.com/topic/172576-variable-dont-display/ Share on other sites More sharing options...
wildteen88 Posted August 31, 2009 Share Posted August 31, 2009 Variables are not parsed within single quotes. Remove the ' around $sitename Link to comment https://forums.phpfreaks.com/topic/172576-variable-dont-display/#findComment-909721 Share on other sites More sharing options...
newbtophp Posted August 31, 2009 Author Share Posted August 31, 2009 Variables are not parsed within single quotes. Remove the ' around $sitename dont work it justs shows $sitename Link to comment https://forums.phpfreaks.com/topic/172576-variable-dont-display/#findComment-909735 Share on other sites More sharing options...
MasterACE14 Posted August 31, 2009 Share Posted August 31, 2009 wildteen88 means change this $t->setNick('$sitename'); to this $t->setNick($sitename); Link to comment https://forums.phpfreaks.com/topic/172576-variable-dont-display/#findComment-909736 Share on other sites More sharing options...
akitchin Posted August 31, 2009 Share Posted August 31, 2009 in addition, $sitename will not exist in change_nick()'s scope because you aren't passing it to the function or declaring it as global. Link to comment https://forums.phpfreaks.com/topic/172576-variable-dont-display/#findComment-909737 Share on other sites More sharing options...
Batosi Posted August 31, 2009 Share Posted August 31, 2009 in addition, $sitename will not exist in change_nick()'s scope because you aren't passing it to the function or declaring it as global. Exactly so do global $t, $sitename; Link to comment https://forums.phpfreaks.com/topic/172576-variable-dont-display/#findComment-909746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.