I have a problem with PHP and I need your help to understand it, here is my code, create some attributes as an array to store information:
Pet.php
<?php
class mascota {
//Atributos
public $tipo = array();
public $nombre = array();
public $color = array();
public $raza = array();
public $edad = array();
// Métodos
public function mostrarMascota($nro,$tp,$nom,$col,$raz,$ed) {
array_push($tipo,$tip);
array_push($nombre,$nom);
array_push($color,$col);
array_push($raza, $raz);
array_push($edad,$ed);
$respuesta =
"
<table BORDER>
<tr>
<td>
$tipo[$nro];
</td>
<td>
$nombre[$nro];
</td>
<td>
$color[$nro];
</td>
<td>
$raza[$nro];
</td>
<td>
$edad[$nro];
</td>
</tr>
</table>";
return $respuesta:
}
}
?>
Index.php
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width-device-width, initial-scale-1.0">
<title>LABORATORIO NRO 3 - INGENIERÍA WEB</title>
</head>
<body>
<div class="container">
<h1>LABORATORIO NRO3 - INGENIERÍA WEB</h1>
<div class="creando-objeto">
<h2>Creación del objeto mascota</h2>
<table BORDER>
<tr>
<th>Mascota</th>
</tr>
<tr>
<td>Tipo</td>
</tr>
<tr>
<td>Nombre</td>
</tr>
<tr>
<td>Color</td>
</tr>
<tr>
<td>Raza</td>
</tr>
<tr>
<td>Edad</td>
</tr>
</table>
<?php
include('./Modelo/Mascota.php');
$objMascota = new mascota();
echo $objMascota->mostrarMascota(0,"PERRO","MILANESO","NEGRO",
"PASTOR ALEMAN",5);
?>
</div>
</div>
</body>
</html>
The result is this, I am just learning php and it seems to me that it is a problem of the arrays that I am doing wrong