{
  "id": "09",
  "content": [
    {
      "type": "heading",
      "text": "Files, Include/Require & OOP Basics"
    },
    {
      "type": "text",
      "html": "<pre><code>&lt;?php\n $data = file_get_contents('notes.txt');\n file_put_contents('out.txt', $data);\n</code></pre>"
    },
    {
      "type": "text",
      "html": "<pre><code>&lt;?php\n require 'config.php'; // fatal on failure\n include 'helpers.php'; // warning on failure\n</code></pre>"
    },
    {
      "type": "text",
      "html": "Simple class:<pre><code>&lt;?php\n class Greeter { public function hi(string $n): string { return \"Hello $n\"; } }\n echo (new Greeter())-&gt;hi('Xavier');\n</code></pre>"
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "Difference between include and require:",
        "options": [
          {
            "id": "a",
            "text": "require causes a fatal error if file missing; include only warns"
          },
          {
            "id": "b",
            "text": "They are the same"
          },
          {
            "id": "c",
            "text": "include is faster"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Which function reads an entire file into a string?",
        "options": [
          {
            "id": "a",
            "text": "file_get_contents"
          },
          {
            "id": "b",
            "text": "read_all"
          },
          {
            "id": "c",
            "text": "fread_all"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}