PHP函数未到达最里面的嵌套if块
所以我用条件做了一些测试,出于某种原因,我无法让这个函数到达最里面的if/else集合 我希望有人能告诉我我做了什么PHP函数未到达最里面的嵌套if块,php,if-statement,nested,conditional,Php,If Statement,Nested,Conditional,所以我用条件做了一些测试,出于某种原因,我无法让这个函数到达最里面的if/else集合 我希望有人能告诉我我做了什么 function verifyStridersIdentity($post_name, $modpass) { //is the post name strider? //this part works if (strtolower($post_name) == 'strider') { //is the mod pass set?
function verifyStridersIdentity($post_name, $modpass) {
//is the post name strider?
//this part works
if (strtolower($post_name) == 'strider') {
//is the mod pass set?
//this part ALSO works
if (!empty($modpass)) {
//modpass has some kind of value
$staff_name = md5_decrypt($modpass, KU_RANDOMSEED);//is it actually Strider though?
//this seems to be the block I am having trouble getting into?
//I can not get a value of either of these next two return statements.
if ($staff_name == $post_name) {
return 'This Works, It\'s me!'; //this is Strider
}
else {
return 'This is '.$staff_name.' attempting to be Strider. This has been logged.';
}
}
else {
return 'Anonymous Test';
}
}
else {
return $post_name;
}
}
我希望内联注释能够很好地解释发生了什么,但如果没有,请向我询问更多信息。当我从原始类调用函数时,我使用了以下代码:
$post_name = verifyStridersIdentity($post_name,$modpass);
问题是$modpass实际上并不存在,所以我发送的是一个空白
因此,纠正呼叫应该是这样的:
$modpass = '';
if (isset($_POST['modpassword'])) {
$modpass = $_POST['modpassword'];
}
$post_name = verifyStridersIdentity($post_name,$modpass);
好的,我感谢所有读过这篇文章的人,但事实证明我实际上调用了错误的函数。我将发布解决方案。因此它工作正常
$modpass
为空,因此它跳过了if
块,转到了else
块。函数是否因此返回了匿名测试
?正确,这让我看到了在调用类中输入参数的内容。