I'm doing an echo of an object that is an html string, first I declare it in an array and then I convert it into an object, I do a var_dump
and if it comes out but when doing the echo it goes out that the property is not an object. Can you tell me what I'm doing wrong? thank you very much.
htmlclientes.php
class HtmlClientes extends Clientes
{
protected $item;
public function htmlItem($numer)
{
var_dump($numer);
if ($numer % 6 == 0) {
return $this->item = (object) array(
'itemtop' => '<li class="flex flex-center-horizontal logo8">',
'itembottom' => '</li>'
);
}
}
}
index.php
<?php
$i = 0;
foreach ($clientes->getDatos() as $cliente){
$cliente = (object) $cliente;
$html = $clientes->htmlItem($i);
var_dump($html);
echo $html->itemtop;
?>
<img src="<?php echo $rootUrl; ?>assets/images/img<?php echo $cliente->imagen; ?>" alt="<?php echo $cliente->nombre; ?>" />
<?php
echo $html->itembottom;
$i++;
}
?>
result var_dump
int(0)
object(stdClass)#5 (2) {
["itemtop"]=>
string(46) "<li class="flex flex-center-horizontal logo8">"
["itembottom"]=>
string(5) "</li>"
}