xyn Posted August 12, 2006 Share Posted August 12, 2006 Hey.I have got a list of functions but I have a problem.the thing is I forgotte how to call a function andI don't think the functions been created correctly.function is:function Test(){echo 'test';}I can't remember how to call it, I tried call_user_function(Test);and realised it was wrong! :/ Quote Link to comment https://forums.phpfreaks.com/topic/17338-functions/ Share on other sites More sharing options...
poirot Posted August 12, 2006 Share Posted August 12, 2006 Test(); Quote Link to comment https://forums.phpfreaks.com/topic/17338-functions/#findComment-73702 Share on other sites More sharing options...
Demonic Posted August 12, 2006 Share Posted August 12, 2006 [code]<?phpfunction Test(){echo 'test';}$post = $_POST['submit'];if(isset($post)){Test();}?><form method="post"><input type="submit" name="submit"></form>[/code]that would echo test when you push submit. Quote Link to comment https://forums.phpfreaks.com/topic/17338-functions/#findComment-73722 Share on other sites More sharing options...
xyn Posted August 12, 2006 Author Share Posted August 12, 2006 Yeah, I usually do if(isset($_POST['submit'])){code}else{form}And i have a logout function which logs out the userAlthough my problem is Sessions aren't changing :/.My function:function LogOut(){$_SESSION['LoggedIn'] = false;$_SESSION['user'] = "";}I use:if( $x = logout ){LogOut();}and nothing, but the redirect in that function worksso does the echo :/ Quote Link to comment https://forums.phpfreaks.com/topic/17338-functions/#findComment-73726 Share on other sites More sharing options...
wildteen88 Posted August 12, 2006 Share Posted August 12, 2006 You'll want to use this comparing x[code=php:0]if( $x == 'logout' ){LogOut();}[/code]Otherwise you are assigning $x to the constant logout all the time. Also make sure you have session_start() at the top of your script. And use session_destroy to destroy the session when they logout. Quote Link to comment https://forums.phpfreaks.com/topic/17338-functions/#findComment-73729 Share on other sites More sharing options...
xyn Posted August 12, 2006 Author Share Posted August 12, 2006 I had it $x == "logout" but i'll try session_destroy();And session_start(); is at the top of the index page where the scripts are included.:] Quote Link to comment https://forums.phpfreaks.com/topic/17338-functions/#findComment-73730 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.