I understand the working of this method getSummaryLine?

class ShopProduct
{
public $numPages;
public $playLength;
public $title;
public $producerMainName;
public $producerFirstName;
public $price;
public function __ construct(
string $title,
string $firstName,
string $mainName,
float $price,
int $numPages = 0,
int $playLength = 0
) {
$this->title = $title;
$this->producerFirstName = $firstName;
$this->producerMainName = $mainName;
$this->price = $price;
$this->numPages = $numPages;
$this->playLength = $playLength;
}
public function getProducer()
{
return $this->producerFirstName
. $this->producerMainName;

public function getSummaryLine()
{
$base
= ” { $this->title} ( { $this->producerMainName),
$base .= ” { $this->producerFirstName}
return $base;}}

<?php
namespace popp\ch03\batch11;

/* listing 03.30 */
class ShopProduct
{
 public $numPages;
 public $playLength;
 public $title;
 public $producerMainName;
 public $producerFirstName;
 public $price;
/* /listing 03.30 */
 public $type="book";
/* listing 03.30 */

 public function __construct(
 string $title,
 string $firstName,
 string $mainName,
 float $price,
 int $numPages = 0,
 int $playLength = 0
 ) {
 $this->title = $title;
 $this->producerFirstName = $firstName;
 $this->producerMainName = $mainName;
 $this->price = $price;
 $this->numPages = $numPages;
 $this->playLength = $playLength;
}

 public function getNumberOfPages()
{
 return $this->numPages;
}

 public function getPlayLength()
{
 return $this->playLength;
}

 public function getProducer()
{
 return $this->producerFirstName . ""
 . $this->producerMainName;
}
/* /listing 03.30 */

 public function setType(string $type)
{
$this->type=$type;
}
/* listing 03.31 */

 public function getSummaryLine()
{
 $base = "{$this->title} ( {$this->producerMainName}, ";
 $base .= "{$this->producerFirstName} )";
 if ($this->type == 'book') {
 $base .= ": page count - {$this->numPages}";
 } elseif ($this->type == 'cd') {
 $base .= ": playing time - {$this->playLength}";
}
 return $base;
}
/* /listing 03.31 */
/* listing 03.30 */
}
/* /listing 03.30 */


I understand the working of this method getSummaryLine?

public function getSummaryLine()
{
$base
= ” { $this->title} ( { $this->producerMainName),
$base .= ” { $this->producerFirstName}
return $base;}}
April 7th 20 at 15:25
2 answers
April 7th 20 at 15:27
Solution
@Anika.Morar93 the same code from the book Zandstra, everything is described. Why here to copy-paste it, if I write exactly the same explanation? Read and reread the source until you fully understand it.
I just read - neva_Treutel32 commented on April 7th 20 at 15:30
@Anika.Morar93,
Read and reread the source until you fully understand it.
- khalil_Treutel commented on April 7th 20 at 15:33
April 7th 20 at 15:29
This is because you are ignorant. This is the basics of the syntax. Suggest to close the editor and open a PHP Doc
This method just builds a string and returns it.
The operator .= combines line

$text = 'Bob';
$text .= 'DOE';
Will Return 'John DOE'

PS all of your questions from ignorance of the language. Go teach and then try to write
me about the concatenation was clear and so - neva_Treutel32 commented on April 7th 20 at 15:32
@Anika.Morar93, what do you then not understand? - Bonnie.Barrows commented on April 7th 20 at 15:35
He's just dyslexic. Can't a normal question to ask. every sentence longer than two words are given to him with great difficulty.
He then again the same question was asked, and there gave birth, but about the curly parenthesis. - lavonne_Kloc commented on April 7th 20 at 15:38

Find more questions by tags PHP