Weird issue

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jan 07, 2013 11:02 pm

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) {
      if(empty($data) && $multiPasswords) {
      } elseif($multiPasswords && $data != $multiData) {
   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);


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 ?

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests