这一行代码有什么问题? (php里面的php)

I'm new to php. I have the following line in a functions.php file of my WordPress site. I think there is something wrong with the way I formatted get_the_bag. Can someone let me know what is wrong?

$output .= "<span class='bag-item'>. get_the_bag(); .</span>";

  1. You dropped various concatenation stuff and a function call into the middle of a string
  2. You terminated the statement (with a ;) after your function call

You want:

$output .= sprintf("<span class='bag-item'>%s</span>", get_the_bag());

Or

$output .= "<span class='bag-item'>" . get_the_bag() . "</span>";

(Both assuming that get_the_bag returns an HTML safe string. If it doesn't you need to wrap that function call with htmlspecialchars).

Remove the semicolon from after get_the_bag() and place speechmarks after the first span and before the second:

$output .= "<span class='bag-item'>". get_the_bag() ."</span>";
try this 

$output .= "<span class='bag-item'>" . get_the_bag() . "</span>";