1/*
2For loop in php
3*/
4
5<?php
6for ($i = 0; $i < 10; $i++) {
7 echo $i."<br>";
8}
9?>
1static float CalculatePower(float x, int y)
2 {
3 float temp;
4 if (y == 0)
5 return 1;
6 temp = CalculatePower(x, y / 2);
7 if (y % 2 == 0)
8 return temp * temp;
9 else
10 {
11 if (y > 0)
12 return x * temp * temp;
13 else
14 return (temp * temp) / x;
15 }
16 }
1<?php
2$songs = $_POST["songs"];
3//$songs = Array("one","two","three");
4foreach ($songs as $song)
5{
6 $songStr = test_input($song);
7 $songsOut .= "<li>$songStr</li>";
8};
9
10$songList = "Songs: <ol> $songsOut </ol> \r\n";
11echo $songList;
12
13function test_input($data)
14{
15 $data = trim($data);
16 $data = stripslashes($data);
17 $data = htmlspecialchars($data);
18 return $data;
19}
20
21?>