webForumDet fria alternativet

Beräkningar i infällda argument

1 svar · 370 visningar · startad av higa

higaMedlem sedan aug. 2000359 inlägg
#1

Hur gör jag för att utföra beräkningar i infällda argument?

Dvs om jag skriver t ex

print FIL <<_HTML_;
...lite html kod...
<DIV ID="$div[$i]" style="position:absolute; left: 4px; top: (4+90*$i)px">
...lite mer html kod...
_HTML_

för att generera ett lageruppbyggt HTML dokument så blir det ju t ex (när $i står på 3)
"top: (4+90*3)px" i stället för "top: 274px" som jag vill ha.

Mvh Higa

CssonMedlem sedan feb. 2000438 inlägg
#2

Detta borde funka:

$foo = 4 + 90 * $i;
$foo .= "px";

print FIL <<_HTML_;
...lite html kod...
<DIV ID="$div[$i]" style="position:absolute; left: 4px; top: $foo">
...lite mer html kod...
_HTML_

/Csson

137 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
133 ms — hämta tråd, inlägg och bilagor (db)