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.