title: PHP OOP returning and calling single array value
body: <p>I'm in the process of learning to use OOP in php, I'm having a few issues with what is probably a really simple solution that I'm just not using the right search terminology to find.</p>
  
  <p>I have my class </p>
  
  <pre><code>class user {
  
      function getUser() {
  
          if ($_SESSION['status'] == "authorized") {
  
              $conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
  
              $sql = "SELECT * FROM users WHERE username = :username";
  
              $st = $conn-&gt;prepare( $sql );
  
              $st-&gt;bindValue( ":username", $_SESSION['usernames'], PDO::PARAM_STR );
  
              $st-&gt;execute();
  
              $row = $st-&gt;fetch();
  
              $conn = null;
  
              return $row;
  
          }
      }
  }
  </code></pre>
  
  <p>and then in my template file i'm calling the following</p>
  
  <pre><code>$user = new user();
  echo $user-&gt;getUser-&gt;icon;
  </code></pre>
  
  <p>hopefully the bottom line shows what i'm trying to call, basically in the sql results I'm after just calling $row['icon']; directly from the return array.</p>
  
  <p>is this possible? if so could someone point out the terminology i'm missing</p>
  
  <p>Thanks in advance</p>