WhiteCube Posted December 10, 2007 Share Posted December 10, 2007 hi all! I've got this php script here.. but it doesn't seem to work when in a function! <?php $username = "sss"; $exe = "users"; $exe(); function users() { echo "username=$username"; } ?> While reading this.. it should echo out.. "username=ssss".. right? But I keep getting "username=" just that!! Can someone tell me what's going on? Thanks! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 10, 2007 Share Posted December 10, 2007 make $username global in your function function users() { global $username; ... Quote Link to comment Share on other sites More sharing options...
WhiteCube Posted December 10, 2007 Author Share Posted December 10, 2007 ;D Thanks man! Your the greatest!! Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 10, 2007 Share Posted December 10, 2007 Or change the function so it takes a parameter: function users ($name){ echo "username=$name"; } then use: $exe($username); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.