PHP 函数没有到达最内层的嵌套 if 块
PHP function not reaching the innermost nested if block
所以我做了一些条件测试,由于某种原因我无法让这个函数到达最里面的一组 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?
//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;
}
}
我希望内联评论能很好地解释发生了什么,但如果没有,请向我询问更多信息。
当我从原始 class 调用函数时,我使用了以下代码:
$post_name = verifyStridersIdentity($post_name,$modpass);
问题是 $modpass 实际上并不存在,所以我发送的是空白。
因此,纠正电话应该是这样的:
$modpass = '';
if (isset($_POST['modpassword'])) {
$modpass = $_POST['modpassword'];
}
$post_name = verifyStridersIdentity($post_name,$modpass);
所以我做了一些条件测试,由于某种原因我无法让这个函数到达最里面的一组 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?
//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;
}
}
我希望内联评论能很好地解释发生了什么,但如果没有,请向我询问更多信息。
当我从原始 class 调用函数时,我使用了以下代码:
$post_name = verifyStridersIdentity($post_name,$modpass);
问题是 $modpass 实际上并不存在,所以我发送的是空白。
因此,纠正电话应该是这样的:
$modpass = '';
if (isset($_POST['modpassword'])) {
$modpass = $_POST['modpassword'];
}
$post_name = verifyStridersIdentity($post_name,$modpass);