<html><head></head>
<body> <% I=prompt(“Nilai I”,””); X=parseFloat(I) J=prompt(“Nilai J”,””); Y=parseFloat(J) document.write(“Nilai I : “+X+ “Nilai J:”+Y) if(X==Y){ response.write(“nilai I sama dengan nilai J”); } else if(X<Y){ response.write(“Nilai I kurang dari nilai J”); } else{ response.write(“Nilai I lebih dari nilai J”); } %> </script> </body> </html> |
<html><body><form action=“lopp.php” method=”post”>
Masukan Nilai awal: <input type=”text” name=”fname” /> <input type=”submit” /> </form> </body> </html> |
(loop.php)
<?php echo “Perulangan While <br><br>”; $i = $_POST[‘fname’]; while($i<=10) { echo “The number is ” . $i . “<br />”; $i++; } echo”<br><br>”; echo “Perulangan Do..While <br><br>”; $i =$_POST[‘fname’]; do { $i++; echo “The number is ” . $i . “<br />”; } while ($i<=10); echo”<br><br>”; echo “Perulangan For <br><br>”; for ($i = $_POST[‘fname’]; $i<=10; $i++) { echo “The number is ” . $i . “<br />”; } ?> |
<html><head>
<title>Tugas P.Web</title> </head> <body> <? function tanggal(){ $hari=array(“Minggu”,”Senin”,”Selasa”,”Rabu”,”Kamis”,”Jum’at”,”Sabtu”); $bulan=array(“”,”Januari”,”Februari”,”Maret”,”April”,”Mei”,”Juni”,”Juli”,”Agustus”,”September”, “Oktober”,”November”,”Desember”); $tgl=getdate(); echo $hari[$tgl[‘wday’]].”,$tgl[mday]-“.$bulan[$tgl[‘mon’]].”-$tgl[year]”; } ?>Sekarang : <?php tanggal();?><br> <?php function nama () { function x() { echo “I am Love Web Programing.”; } echo “Never Ending.<br/>”; } nama(); x(); ?> $op2 = blabla; $op3 = blabla; function foo($op1) { global $op2, $op3; echo $op1; echo $op2; echo $op3; } ?> <form name=”form1″ method=”post” action=“opp.php”> <p>Operator matematika </p> <p> <input name=”x” type=”text” id=”x”> <select name=”operator” id=”operator”> <option>+</option> <option>-</option> <option>*</option> <option>/</option> </select> <input name=”y” type=”text” id=”y”> <input type=”submit” name=”Submit” value=”Hitung”> </p> </form> </body> </html> |
oop.php
<? function write() { echo “Membuat Funtion di PHP”; } echo “Tugas Pemrogramanan Web”; write(); echo”<br>”; echo”<br>”; function operator($x, $y) { $x = $_POST[‘x’]; $y = $_POST[‘y’]; $operator = $_POST[‘operator’]; if ($operator == ‘+’) { $z=$x+$y; echo “Hasil $x + $y = $z<br>”; } if ($operator == ‘-‘) { $z=$x-$y; echo “Hasil $x – $y = $z<br>”; } if ($operator == ‘*’) { $z=$x*$y; echo “Hasil $x * $y = $z<br>”; } if ($operator == ‘/’) { $z=$x/$y; echo “Hasil $x / $y = $z<br>”; } } operator($x = $_POST[‘x’],$y = $_POST[‘y’]); ?> |