0

I'm having a php noob moment, im looking for a smaller more compact solution to concatenate the "$content" variable which is being echoed as the main content in an external "layout.php" file.

<?php

require_once("Controller/comment_control.php");
$comment = new COMMENT();

$title = "Customer Reviews";
$content = '<div class="comment_box">'   ;
$content .=  $comment->getComments(); 
$content .=  '</div>';

any help condensing this ugly mess is appreciated.

rsahs
  • 3
  • 4

2 Answers2

0

figured it out, encompassing the php call in parenthesis got the end result i wanted

$content = '<div class="comment_box">'  .  ($comment->getComments() ) .  '</div>';
rsahs
  • 3
  • 4
  • Your original code should work exactly the same. If you're seeing the source code, it's a different problem. – Barmar Apr 24 '17 at 07:59
0

Use sprintf()

SPRINTF

Example:

$content = sprintf('<div class="comment_box">%s</div>', $comment->getComments());