Augury Posted February 24, 2014 Share Posted February 24, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/286472-yeild-try-to-get-it-into-my-code-and-yours/ Share on other sites More sharing options...
trq Posted February 24, 2014 Share Posted February 24, 2014 What exactly is the question? Quote Link to comment https://forums.phpfreaks.com/topic/286472-yeild-try-to-get-it-into-my-code-and-yours/#findComment-1470383 Share on other sites More sharing options...
QuickOldCar Posted February 24, 2014 Share Posted February 24, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/286472-yeild-try-to-get-it-into-my-code-and-yours/#findComment-1470455 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.