ataria Posted May 3, 2007 Share Posted May 3, 2007 Okay. What I am looking to do is run a variable into a function ( function($variable); ) and then, have it at the end, predefine it in the function. so, the script would look likeeee. $variable = $row[variable]; function($variable); and, then I can use it on the rest of the script as $variable. is that possible, If so, how do i do it? Quote Link to comment Share on other sites More sharing options...
ataria Posted May 3, 2007 Author Share Posted May 3, 2007 anyone? Quote Link to comment Share on other sites More sharing options...
john010117 Posted May 3, 2007 Share Posted May 3, 2007 First of all, please wait at least an hour before double posting. We all have lives, you know. Second of all, care to elaborate on your problem? Quote Link to comment Share on other sites More sharing options...
ataria Posted May 3, 2007 Author Share Posted May 3, 2007 Okay. I'll just make a quick little code snippet. <?php // would be the function. function secure_int($variable){ $variable = intval($variable); return $variable; } // would be the script. secure_int($id); echo "Your ID is ".$id."!"; ?> see how I didn't use "$id = function($id);" is that possible? =/ Quote Link to comment Share on other sites More sharing options...
ataria Posted May 4, 2007 Author Share Posted May 4, 2007 .... anyone? Quote Link to comment Share on other sites More sharing options...
lalabored Posted May 4, 2007 Share Posted May 4, 2007 Why don't you want to use $id = function($id)? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 4, 2007 Share Posted May 4, 2007 <?php // would be the function. function secure_int($variable) { return intval($variable); } // would be the script. $id = secure_int($id); echo "Your ID is ".$id."!"; ?> the amazing thing here is that you ave managed to generate a function that does the exact same job as an already avialable built in function AND given it a longer name. if you look at the code you could just do this and get exactly teh same result with a little time saving... <?php echo "Your ID is ". intval($id) ."!"; ?> or (if you use $id more in the script) <?php $id = intval($id); echo "Your ID is ". $id ."!"; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted May 4, 2007 Share Posted May 4, 2007 <?php function secure_int(&$variable){ $variable = intval($variable); } secure_int($id); echo "Your ID is ".$id."!"; ?> 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.