Jump to content

Yeild: try to get it into my code and yours!


Augury

Recommended Posts

I have a "while" statement with a switch.  I've tried embedding a second function but apparently I'm too stoopid to get it to re-reference it.  Which is typical.

 

But I saw this Generator class that has a yield.  Is the yield thing any good?  There were no comments on php.net manual.

MemberRouter.snip.php

To get the required help, it's best to show your relevant code.

 

If your question is how to add that function to your own code...

 

include the file with that function or paste the function say beginning of your php code and outside of any loops

wherever you need to use that function, call on that function

 

 

Example

 

function MemberRouter ($routeme, $hailPostData) {  $Routed = NULL;

    if ($_SESSION['AMember']["isloggedin"] == 'TRUE') {
            if (!empty($hailPostData) && $hailPostData !== 1) {
                $Routed = $hailPostData; include $hailPostData; return $Routed;}
            else {
                $Routed = 1; include 'CKmembers.php'; return $Routed;}
    } else { $Routed = 0;}

    if (isset($_POST['submit'])) {
        if (self::PostData()) {
            if (empty($routeme)) { $routeme = $_POST['submit']; }
        } else {
        $routeme = "routeback"; $Routed = $_SERVER["PHP_SELF"]; include $_SERVER["PHP_SELF"]; return 0;
          }
    }

    if ($_SESSION['AMember']["isloggedin"] == 'TRUE') { include 'CKmembers.php'; return 1;}
        else {
            include 'log.php';
         }

    while (!$out) {
    switch ($routeme)
    {
            case "routeback":
            $Routed = '$_SERVER["PHP_SELF"]'; include $_SERVER["PHP_SELF"]; return 1;
            $out = 1;
            break;

            case "login":
                $ML = self::MemberLogin();
                if ($ML) {
                    $_SESSION['AMember'] = array('isloggedin' => 'TRUR', RID => '', Username => $_SESSION['field']['username'], ipaddress => '', time => '');  //need site/server prob.
                    $routeme = "loggedin"; break;
                }
                if ($ML = 'who') {
                    $Routed = "loginFAILED -- possible miss 1 lo";
                    $routeme = "routeback"; break;
                }
            break;
    }
    }
}
 
//this will run the function, you will need to use your variables as the arguments
echo MemberRouter ($routeme, $hailPostData);

 

Take note that another file named CKmembers.php is being included within the function, most likely is the member sessions script

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.