        <?php
        class Question
{
    public $text;           // текст вопроса
    public $points = 5;     // число баллов, по умолчанию 5
    public $answers;        // варианты ответов
    public $correctAnswer;  // правильный ответ
}
function createQuestions()
{
    // Создаем пустой массив
    $questions = [];

    // Создаем и заполняем первый объект
    $q = new Question;
    $q->text = "Какая планета располагается четвертой по счету от Солнца?";
        // Кладем вопрос в массив
    $questions[] = $q;

    // Создаем второй объект
    $q = new Question;
 $q->text = 'Какой город является столицей Великобритании?';
           $questions[] = $q;
      $q = new Question;
 $q->text = 'Кто придумал теорию относительности?';
           $questions[] = $q;
    return $questions;
}
function printQuestions($questions)
{
    $number = 1; // номер вопроса

    foreach ($questions as $question) {
        echo "{$number}. {$question->text}\n\n";

        echo "Варианты ответов:\n";

        foreach ($question->answers as $letter => $answer) {
            echo "  {$letter}. {$answer}\n";
        }

        $number++; 
    }
}

$q1 = new Question;

$q1->points = 10; // 10 баллов за ответ
$q1->answers = array('a' => 'Венера', 'b' => 'Марс', 'c' => 'Юпитер', 'd' => 'Меркурий'); // Варианты ответа
$q1->correctAnswer = 'b'; // Правильный ответ

// Вопрос 2
$q2 = new Question;

$q2->points = 5;
$q2->answers = array('a' => 'Париж', 'b' => 'Москва', 'c' => 'Нью-Йорк', 'd' => 'Лондон');
$q2->correctAnswer = 'd';

// Вопрос 3
$q3 = new Question;

$q3->points = 30;
$q3->answers = array('a' => 'Джон Леннон', 'b' => 'Джим Моррисон', 'c' => 'Альберт Эйнштейн', 'd' => 'Исаак Ньютон');
$q3->correctAnswer = 'c';
        

$questions = createQuestions();
printQuestions($questions);


?>
