Arbitus Posted November 16, 2008 Share Posted November 16, 2008 I'm having problems with functions. This is my first time actualy using functions in a script so bare with me. How would I be able to create a functions.php, and in this file one of the functions created would check to see if the users session is active. Right now I'm trying this functions.php <?php //Functions.php! function session_check() { if(isset($_SESSION['admin_id'])) { ?> index2.php <?php include("../Sources/functions.php"); session_check(); echo "hello!"; } else { echo "no hello!"; } ?> I know I'm most likely doing something terrible here. Link to comment https://forums.phpfreaks.com/topic/132990-functions/ Share on other sites More sharing options...
Mark Baker Posted November 16, 2008 Share Posted November 16, 2008 A function should be a self-contained block of code, optionally accepting parameters from the routine that calls it, and optionally returning a value to the script that calls it. function session_check() if (isset($_SESSION['admin_id'])) { return true; } else { return false; } } if (session_check()) { echo 'hello'; } else { echo 'something else'; } Link to comment https://forums.phpfreaks.com/topic/132990-functions/#findComment-691654 Share on other sites More sharing options...
Arbitus Posted November 16, 2008 Author Share Posted November 16, 2008 Thanks so much! Didn't even think of it that way Link to comment https://forums.phpfreaks.com/topic/132990-functions/#findComment-691656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.