Jump to content

Functions


xyn

Recommended Posts

Hey.
I have got a list of functions but I have a problem.
the thing is I forgotte how to call a function and
I 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! :/
Link to comment
https://forums.phpfreaks.com/topic/17338-functions/
Share on other sites

Yeah, I usually do if(isset($_POST['submit'])){
code
}else{
form
}

And i have a logout function which logs out the user
Although 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 works
so does the echo :/
Link to comment
https://forums.phpfreaks.com/topic/17338-functions/#findComment-73726
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/17338-functions/#findComment-73729
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.