I have a PHP class called ResetPassword. Within this class is a switch which will return a different string containing the required HTML.
This is the code below (I have omitted a few of the cases for the sake of brevity, there is also a default case which returns NULL)
public function get_display_block($displayblock) {
switch ($displayblock) {
case 'EnterNewPassword':
$displayblock = '
<form action="resetpassword.php" method="post">
<fieldset class="login">
<legend>Enter your information in the form below to reset your password: </legend>
<div><label for="password1">Password :</label>
<p><input type="password" name="password1" size="40" maxlength="60" /></p> </div>
<div><label for="password2"><span class="required">*</span>Retype Password :</label>
<p><input type="password" name="password2" size="40" maxlength="60" /></p> </div>
<br />
</fieldset><br />
<br />
<div align="center"><input type="submit" name="submit" value="Submit My Information!" \></div>
</form>
';
return $displayblock;
break;
case 'THIS_ISNT_WORKING':
$displayblock = '
<form action="changepassword.php" method="post">
<fieldset class="login">
<legend>Enter your information in the form below to reset your password: </legend>
<div><label for="password1">Old Password : </label>
<p><input type="password" name="oldpassword" size="40" maxlength="60" /></p> </div>
<div><label for="password1">New Password :</label>
<p><input type="password" name="password1" size="40" maxlength="60" /></p> </div>
<div><label for="password2"><span class="required">*</span>Retype New Password :</label>
<p><input type="password" name="password2" size="40" maxlength="60" /></p> </div>
<br />
</fieldset><br />
<br />
<div align="center"><input type="submit" name="submit" value="Submit My Information!" \></div>
</form>
';
return $displayblock;
break;
} // end of switch
} //end of method
When calling the class/switch on my main page, The below code works fine.
$reset = new ResetPassword();
$displayblock = $reset->get_display_block('EnterSecretAnswer');
However, when attempting to call THIS_ISNT_WORKING nothing displays. A var_dump on $displayblock returns NULL.
$reset = new ResetPassword();
$displayblock = $reset->get_display_block('THIS_ISNT_WORKING');
var_dump($displayblock);
If I call any of the other cases (the ones omitted previously) it returns the required HTML.
Can anyone see something I am missing here? Any help as usual would be greatly appreciated.
EDIT: I have updated the switch as requested below so that the return statement is outside the switch. The end result is still the same. I have also changed the default case to return a string ("abcd") just to verify that the default case wasn't be called, and it wasnt. Still returning NULL.