格式化HTML表格中的回声输出

I have an object in PHP with 5 attributes using the following code:

<?php
class Person
{
    private $gender, $race, $height, $weight, $eyes_color;
    public function start ($gender,$race,$height, $weight, $eyes_color)
    {
        $this->gender=$gender; 
        $this->race=$race; 
        $this->height=$height;
        $this->weight=$weight;
        $this->eyes_color=$eyes_color;
    }
    public function show_attributes()
    { 
    return sprintf("%s, %s, %s, %s, %s", $this->gender, $this->race, $this->height, $this->weight,$this->eyes_color);
    }
}
$person=new person();
?>

I'm calling this class using the following HTML code

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Class Person</title>
    </head>
    <body>
        <?php
        require_once("Person.php");
        $person->start("Male","Latin","1.83 cm","85 kg","Brown");
        echo $person->show_attributes();
        ?>
    </body>
</html>

Now, that will print something like

Male, Latin, 1.83 cm, 85 kg, Brown

But I want to print something like

 --------------------------------------
|Male | Latin | 1.83 cm | 85 kg | Brown|
 --------------------------------------

Using a HTML table.

I have try a couple of things, but I can't make it happend.

Is there a way to force

echo $person->show_attributes();

to only show one attribute so I can call it from inside a HTML cell table?

Thanks.

Try this

<?php
class Person
{
    private $gender, $race, $height, $weight, $eyes_color;
    public function start ($gender,$race,$height, $weight, $eyes_color)
    {
        $this->gender=$gender; 
        $this->race=$race; 
        $this->height=$height;
        $this->weight=$weight;
        $this->eyes_color=$eyes_color;
    }
    public function show_attributes()
    { 
    return sprintf("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>", $this->gender, $this->race, $this->height, $this->weight,$this->eyes_color);
    }
}
$person=new person();
?>

HTML code:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Class Person</title>
    </head>
    <body>
        <?php
        require_once("Person.php");
        $person->start("Male","Latin","1.83 cm","85 kg","Brown");
        echo "<table>":
        echo "<tr>";
        echo $person->show_attributes();
        echo "</tr>";
        echo "</table>";
        ?>
    </body>
</html>

I don't know how in-depth you're looking to go, but you can load the data into a data modeler/table system like http://backgridjs.com.

I realize that may be completely over the top for what you're looking for, but it's robust and (mostly) easy to learn.