index.php
Código PHP :
<?php
require_once 'pro.php';
require_once 'pantalla.php';
class index
{
public function run()
{
$array = array('animal' => '1414', 'stat' => 'Gestante');
$pantalla = new pantalla();
$txt = new texto();
$txt->show($array,'usuarios');
$pantalla->showIt($txt);
}
}
$haber = new index();
$haber->run();pantalla.php
Código PHP :
<?php
require_once 'interfaceShow.php';
class pantalla
{
public function showIt(interfaceShow $mensaje)
{
echo $mensaje->show();
}
}interfaceShow.php
Código PHP :
<?php
interface interfaceShow
{
public function show($array, $table);
}pro.php
Código PHP :
<?php
require_once 'interfaceShow.php';
class texto implements interfaceShow
{
public function show($array, $table)
{
$nuevo = '';
foreach($array as $clave => $valor){
$nuevo .= $clave." -> ".$valor."<br/>";
}
return $nuevo."<br/> Para la tabla ".$table;
}
public function __toString()
{
return $this->show();
}
}Ademas por que me dice que en la clase texto las variables $array y $table no están definidas siendo que si, ademas las imprimo en un echo y lo hace bien?...
esto es lo que arroja al correr el script:
Código PHP :
Warning: Missing argument 1 for texto::show(), called in C:\xampp\htdocs\a\pantalla.php on line 8 and defined in C:\xampp\htdocs\a\pro.php on line 6 Warning: Missing argument 2 for texto::show(), called in C:\xampp\htdocs\a\pantalla.php on line 8 and defined in C:\xampp\htdocs\a\pro.php on line 6 Notice: Undefined variable: array in C:\xampp\htdocs\a\pro.php on line 9 Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\a\pro.php on line 9 Notice: Undefined variable: table in C:\xampp\htdocs\a\pro.php on line 12 Para la tabla
Ojalá alguien sepa POO en PHP5 y me ayude por que estoy vuelto loco desde hace unos dias...
Muchas gracias !!
