title: PHP OOP - Missing argument 1
body: <p>I'm trying to make the switch to OOP. I found a pdf on the internet written by killerphp that seems useful. Followed his examples up 'till now because I got an error. The output is this:</p>
  
  <blockquote>
    <p>Warning: Missing argument 1 for person::__construct(), called in
    C:\xampp\htdocs\oop\index.php on line 15 and defined in
    C:\xampp\htdocs\oop\class_lib.php on line 8</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>Notice: Undefined variable: persons_name in
    C:\xampp\htdocs\oop\class_lib.php on line 10</p>
  </blockquote>
  
  <pre><code>Stefan's full name: Stefan Mischook
  
  Nick's full name: Nick Waddles
  </code></pre>
  
  <p>This is index.php (the page that I run):</p>
  
  <pre><code>&lt;?php
      require_once('class_lib.php');
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;OOP in PHP&lt;/title&gt;
  &lt;/head&gt;
  
      &lt;body&gt;
          &lt;?php
              // Create object without constructor by calling a method
              $stefan = new person();
              $stefan-&gt;set_name("Stefan Mischook");
              echo "Stefan's full name: " . $stefan-&gt;get_name();
  
              echo "&lt;br&gt;";
  
              // Create object with constructor
              $jimmy = new person("Nick Waddles");
              echo "Nick's full name: " . $jimmy-&gt;get_name();
  
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is the class:</p>
  
  <pre><code>&lt;?php
      // A variable inside a class is called a "property"
      // Functions inside a class are called "methods"
      class person
      {
          var $name;
  
          function __construct($persons_name)
          {
              $this-&gt;name = $persons_name;
          }
  
          function set_name($new_name)
          {
              $this-&gt;name = $new_name;
          }
  
          function get_name()
          {
              return $this-&gt;name;
          }
      }
  
      // $this can be considered a special OO PHP keyword
  
      // A class is NOT an object. The object gets created when you create an instance of the class.
  
      // To create an object out of a class you need to use the "new" keyword.
  
      // When accesign methods and properties of a class you use the -&gt; operator.
  
      // A constructor is a built-in method that allows you to give your properties values when you create an object
  ?&gt;
  </code></pre>
  
  <p>Nevermind the comments, I use them for learning. Thank you very much and please let me know if I need to edit my question before downrating. Cheers!</p>