Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Build a Simple Class | OOP Foundations in PHP
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Object-Oriented PHP

bookChallenge: Build a Simple Class

Recap: Building a PHP Class

  • Class: Blueprint for objects;
  • Properties: Variables that store object data;
  • Methods: Functions that define object behavior;
  • Constructor: Initializes properties when an object is created.

Use these concepts to complete the exercise below.

Tarefa

Swipe to start coding

Write a PHP class named Book that models a book with a title and an author. Your class should have:

  • Properties to store the title and author.
  • A constructor that sets the title and author properties using the provided arguments.
  • A method called displayInfo that outputs the book's title and author in the format: Title: [title], Author: [author].

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 5
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Build a Simple Class

Deslize para mostrar o menu

Recap: Building a PHP Class

  • Class: Blueprint for objects;
  • Properties: Variables that store object data;
  • Methods: Functions that define object behavior;
  • Constructor: Initializes properties when an object is created.

Use these concepts to complete the exercise below.

Tarefa

Swipe to start coding

Write a PHP class named Book that models a book with a title and an author. Your class should have:

  • Properties to store the title and author.
  • A constructor that sets the title and author properties using the provided arguments.
  • A method called displayInfo that outputs the book's title and author in the format: Title: [title], Author: [author].

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 5
single

single

some-alt