I did this but it doesn't work. I need to put user input of width and height into php and draw shape.
echo "<div style='width:<?php $sirina?>;height: <?php $visina?>;border:1px solid black;'";
CodePudding user response:
You don't have to rewrite <?php ?>, just like this:
echo "<div style='width:". $sirina." px;height:'". $visina." px;border:1px solid black;'";
CodePudding user response:
It seems to me that you're not echoing your $sirina and $visina variables properly.
So your code should look something like this:
echo "<div style='width: $sirina px; height: $visina px; border: 1px solid black;'";
CodePudding user response:
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;'";
CodePudding user response:
You can write php code between html tag, html attribute, html tag name so php code should be written in style attribute. like this:
<span><</span>div style="height: <span><</span>?php echo $h;?>px; width: <span><</span>?php echo $w;?>px; "><span><</span>/div>
