How to put php code in the style attribute of a div element?

You don't have to rewrite <?php ?>, just like this:

echo "<div style='width:". $sirina." px;height:'". $visina." px;border:1px solid black;'";

you can use this syntax:

<?= ?>

you can put any variable between this tags and it will echo that variable automatically.

so your code will refactor to this:

echo "<div style='width:<?= $sirina ?>;height: <?= $visina ?>;border:1px solid black;'";