Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Weird issue

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Weird issue

Postby nReCon » Mon Jan 07, 2013 11:09 pm

File 1:
Code: Select all
namespace Lib\Form;
class verifyPassword extends \Lib\Form {
   public $_error;
   private $_data;
   private $_test;
   
   function __construct($data=null, $multiPasswords=false, $multiData=null) {
      $this->_data = $data;
      if(empty($data) && !$multiPasswords) {
         $this->_result(ERROR_FORM_EMPTY_PASSWORD);
      }
      if(empty($data) && $multiPasswords) {
         $this->_result(ERROR_FORM_EMPTY_PASSWORD2);
      } elseif($multiPasswords && $data != $multiData) {
         $this->_result(ERROR_FORM_NOMATCH_PASSWORD);
      }
   }
   private function _result($error) {
      if(!empty($error)) {
         $this->_error = $error;
      } else {
         $this->_error = false;
      }
   }
   public function isVerified() {
      return empty($this->_error) ? true : false;
   }
   public function getData($testerror) {
      if(empty($testerror)) {
         return fancySuperSecretHashPasswordThing();
      } else {
         return false;
      }
   }
}


File 2:
Code: Select all
echo $validator->getData($validator->_error);


Issue:

If I put this code:
Code: Select all
echo "__" . $testerror . "__";

at the top of the getData function it will echo as expected but if i put the same piece of code right after the if-statement it wont echo it and if i echo something not using the $this->_error variable it does echo.

Im very confused to why this is happening. Its like $testerror is being reset somewhere but thats impossible right ?

EDIT: I find that it works if i use SESSION variables instead of a normal variable for $this->_error but is there any other way of doing this that doesnt involve SESSION variables ?
nReCon
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Jan 07, 2013 11:02 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron