Php method question - lesson 4

On the methods lesson, (https://www.codecademy.com/courses/learn-php/lessons/php-classes/exercises/methods)

Step 2 says:
The method should return this statement about the beverage, with <temperature> and <color> replaced with the beverage’s temperature and color :

The correct answer was: return “This beverage is $this->temperature and $this->color.”;

My question is why wouldn’t we need to concatenate this return response with . " " . etc…?

we could that too, but the technique the lesson uses is know as Variable Interpolation in a String.

which i prefer over to the concatenation with . " " ..

1 Like