{
  "id": "05",
  "content": [
    {
      "type": "heading",
      "text": "Functions & Parameters"
    },
    {
      "type": "text",
      "html": "Functions encapsulate logic. Use type hints and return types (PHP 7+)."
    },
    {
      "type": "text",
      "html": "<pre><code>&lt;?php\ndeclare(strict_types=1);\nfunction add(int $a, int $b): int { return $a + $b; }\necho add(2,3);\n</code></pre>"
    },
    {
      "type": "text",
      "html": "Anonymous functions/closures are supported and useful for callbacks."
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "Which defines a function that returns an int?",
        "options": [
          {
            "id": "a",
            "text": "function x(): int { return 1; }"
          },
          {
            "id": "b",
            "text": "function x() { return '1'; }"
          },
          {
            "id": "c",
            "text": "fn x => 1;"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Why use type hints?",
        "options": [
          {
            "id": "a",
            "text": "Catch mistakes earlier and self-document code"
          },
          {
            "id": "b",
            "text": "To slow down code"
          },
          {
            "id": "c",
            "text": "They are mandatory in PHP"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}