title: PHP - cannot build array
body: <p>First things first. Here's the bad code:</p>
  
  <pre><code>public function get_mango($mango_juice) {
      $mango_id       = $this-&gt;mango_id;
      $respons   = array(
          'recipient' =&gt; [ 'id'   =&gt;  $mango_id ],
          'message'   =&gt; [ 'text' =&gt; "$mango_juice" ]
      );
      return $respons;
  }
  </code></pre>
  
  <p>This is a function of the Mango.php file in which is contained the Mango class. Mango is used in the main page (<em>index.php</em>) to provide an answer to what comes from the outside internet (in this case, Facebook).</p>
  
  <p>The code I provided seems to be bad because I checked that <code>$mango_id</code> has a value after I assigned <code>$this-&gt;mango_id</code> but, mysteriously, <code>$respons</code> is neither <code>NULL</code> nor <code>EMPTY</code>! So many <code>error_log("$poor_variable");</code> brought me to this. As an example, if I <code>error_log(var_dump($respons))</code> the only thing I get is nothing, pure nothing. So you can imagine that nothing is returned.
  I performed the error_logs <em>in the right place</em>, so after instantiate the variables described.</p>
  
  <p>If I try to build the array in the following piece of code (actually the part is commented, obviously) <strong>it works!</strong> *"Fantastic!" I said after I noticed that using this workaround the code worked, but I can't put the construction of the array in the main <em>index.php</em> because I will lose all the organization the OOP programming method provides you!</p>
  
  <pre><code>if(!empty($input['entry'][0]['messaging'][0]['sender']['id'])) {
      $sender_id      = $input['entry'][0]['messaging'][0]['sender']['id'];
  
      //the mango class - the constructor put the $sender_id in the mango_id property
      $mango          = new Mango($sender_id);
      //user_input
      $messageText    = $input['entry'][0]['messaging'][0]['message']['text'];
      //I haven't showed this method, but imagine this returns a clean, always non-empty string.
      $mango_answer   = $mango-&gt;talk($messageText);
      //This is where I call the incriminated piece of code.
      $res       = $mango-&gt;compose_answer($mango_answer);
      /**$response = [
          'recipient' =&gt; [ 'id'   =&gt;  $sender_id ],
          'message'   =&gt; [ 'text' =&gt; "$res" ]
      ];*/
  
      $ch = curl_init('https://graph.facebook.com/v2.6/me/messages?access_token='.FBHandler::ACCESS_TOKEN);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($res));
      curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
      curl_exec($ch);
      curl_close($ch);
  }
  </code></pre>
  
  <p><strong>What's happening?</strong></p>
  
  <p><em>PS: I noticed that there were many questions related to <strong>PHP not building arrays</strong>, many of them marked as a duplicate of others where the solution provided was too general, like "upgrade your PHP" or too specific. I can neither upgrade nor check my version of PHP. So, please, help me!</em></p>
  
  <p>[EDIT] <em>My PHP version is 5.3.29</em>. Thanks to @RiggsFolly.</p>