title: Pass a Parameter to a Function in a Class in PHP
body: <p>I'm a total beginner trying to learn PHP.</p>
  
  <p>I have created a class called Image (in a file called image.php) that contains a few basic functions. I'd like to be able to create a 'new' image object associated with a jpeg on my hard drive and then pass that file name as a parameter to the functions in the class to perform their options on it.</p>
  
  <p>All that I want to do at this point is have the function output the image to the browser. Currently, I have the display function working when I call it but I have to name the file right in the function code. How can I define the file name outside the class then pass it into the class function?</p>
  
  <pre><code>class Image
  {
      // property declaration
      public $filename = 'Not set';
  
      public function displayImage()
      {
      // File
      $filename = imagecreatefromjpeg("9.jpg");
  
      // Content type
      header('Content-type: image/jpeg');
  
      // Output
      imagejpeg($filename);
      }
  }
  </code></pre>
  
  <p>Trying to instantiate and call here:</p>
  
  <pre><code>include 'image.php';
  $first = new Image();
  $first-&gt;filename = "9.jpg";
  $first-&gt;displayImage();
  </code></pre>
  
  <p>Thanks in advance!</p>