PHP Bug I cannot see :S

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

LordPolo
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jul 07, 2014 2:54 am

PHP Bug I cannot see :S

Postby LordPolo » Mon Jul 07, 2014 2:59 am

I have a function inside a class which is to add an array of values to an already populated array.

Code: Select all

public function addMessage($to,$from,$clock,$text){
      /**This function is true and correct!*/
      if($this->Friends === false || $this->Friends['friends'] === false){
         return false;
      }
      foreach($this->Friends['friends'] as $friend){
         if($friend['ref'] == strval($to)){
            if($friend['messages'] === false){
               $friend['messages'] = array();
            }
            array_push($friend['messages'],array( "to" => strval($to), "from"=>strval($from),"clock"=>$clock,"text"=>$text));
            return true;
         }
      }
      return false;
   }


The problem is, whenever executed, no matter what the data (tried faking it), the function will always
return false. I believe it is the 2 tests at the beginning but my inexperience in php is a bit of an issue.
Thanks all

kladrian
New php-forum User
New php-forum User
Posts: 12
Joined: Thu Aug 14, 2014 1:13 am
Contact:

Re: PHP Bug I cannot see :S

Postby kladrian » Thu Aug 14, 2014 11:27 am

try to write some echos to see which "false" returns or even better, use xdebug and use breakpoints

---
kladrian


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 5 guests