PHP Help

Hitman
Soldato
Joined
25 Feb 2004
Posts
2,837
Hey,

Trying to make something in PHP, but stuck on this one thing. I'll try to explain:

I have a form with 2 variables. For the sake of this post, I'll name them $user and $pass. After the form has been submitted (by submitting the data to itself), something like this is ran:

$returnVals = DoThis( $user, $pass );

"DoThis" is a function, and for the sake of this post, does this:

function DoThis( $user, $pass )
{
include( 'a_special_file.php' );
$newfile = new NewLa( );
$newfile->DoThat( $user, $pass );
}


This passes the variables $user and $pass to the new file, a_special_file.php. Here, something like this can be done:

function DoThat( $user, $pass )
{
if ($user = '1')
return 0;
}


What I need to do is pass the return value from a_special_file to the one where it all originated (where the form / "DoThis" function is).

How could I go about doing this, as it doesn't seem to be working?

I hope this is all understandable, got a feeling it probably isn't :(

Cheers in advanced
 
This passes the variables $user and $pass to the new file, a_special_file.php.

no it doesn't. the code in the included file just becomes part of the original script. in your example, the script would run like this......

Code:
function DoThis( $user, $pass )
{
    function DoThat( $user, $pass )
    {
        if ($user = '1')
        return 0;
    }
    $newfile = new NewLa( );
    $newfile->DoThat( $user, $pass );
}

i'm hoping the if($user = 1) is just a typo and not the cause of your problem. :p
 
If all you're doing in a_special_file.php is defining a function, just include it before hand and call the function when needed:
Code:
include( 'a_special_file.php' );

function DoThis( $user, $pass )
{
    $returnValue = DoThat($user, $pass);
    
    // Other stuff.
}
 
Back
Top Bottom