340 likes | 479 Views
PHP. 1 12 123 1234 12345 http://www.thaiall.com/php/training49.htm http :// www.thaiall.com/article/teachpro.htm Update : August 23,2012. PHP. My case was in Foxserv Server Suit 1. http ://sourceforge.net/projects/foxserv/ [FoxServ3.1Beta1.exe]
E N D
PHP 1 12 123 1234 12345 http://www.thaiall.com/php/training49.htm http://www.thaiall.com/article/teachpro.htm Update : August 23,2012
PHP My case was in Foxserv Server Suit 1. http://sourceforge.net/projects/foxserv/ [FoxServ3.1Beta1.exe] 2. Change [foxserv] in httpd.conf to [easyserv] 3. Press Go for PHP 4.2.2 and Apache 1.3.27 4. Root in C:\FoxServ\www 5. http://127.0.0.1/x.php Question How do you write 1 – 5 in separate lines? Remark One to five in x.php On webserver that support PHP Language
This source code in x.php was not the answer <? echo " 1 2 3 4 5 "; ?>
ok <pre><? echo " 1 2 3 4 5 "; ?></pre>
ok 1<br>2<br>3<br>4<br>5
ok <pre> 1 2 3 4 5 </pre>
no <? echo "1"; echo "2"; echo "3"; echo '4'; echo '5'; ?>
ok <? echo "1<br>"; echo "2<br>"; echo "3<br>"; echo '4<br>'; echo '5<br>'; ?>
no <pre><? echo "1\n"; echo "2\n"; echo "3\n"; echo '4\n'; echo '5\n'; ?></pre>
ok <pre><? echo " 1\n 2\n 3\n 4\n 5\n "; ?></pre>
ok <pre><? echo "1\n2\n3\n4\n5\n"; ?></pre>
ok <? echo ++$i . "<br>"; ?> <? echo ++$i . "<br>"; ?> <? echo ++$i . "<br>"; ?> <? echo ++$i . "<br>"; ?> <? echo ++$i . "<br>"; ?>
no ..It was not error and warning If you do not declare <? echo $i++."<br>"; echo $i++."<br>"; echo $i++."<br>"; echo $i++."<br>"; echo $i++."<br>"; ?>
ok <pre><? for($i=1;$i<=5;$i++) echo "$i\n"; ?></pre>
ok <ol><? for($i=1;$i<=5;$i++) echo "<li>"; ?></ol>
ok <? for($i=1;$i<=5;$i++) echo "$i<br>"; ?>
no <? for($i=1;$i<5;$i++) { echo "$i<br>"; } ?>
ok <? for($i=1;$i<=5;$i++) { ?> <? echo "$i<br>"; ?> <? } ?>
ok <? for($i=1;$i<=5;$i++) { ?> <? echo "$i"; ?> <br> <? } ?>
ok <? for($i=1;$i<=5;$i++) { ?> <?=$i?> <br> <? } ?>
ok <pre> <? for($i=1;$i<=5;$i++) { ?> <?=$i."\n";?> <? } ?> </pre>
ok <pre><? for ($i=49;$i<54;$i++) echo chr($i).chr(10); ?></pre>
ok <? $s ="12345"; for($i=0;$i<5;$i++) echo substr($s,$i,1)."<br>"; ?>
ok <? foreach (range(1,5) as $x) { echo "$x<br>"; } ?>
ok <? $a = array(1,2,3,4,5); foreach ($a as $x) { echo "$x<br>"; } ?>
no <? $i = 0; while ($i <= 5) { echo $i; echo "<br>"; $i = $i + 1; } ?>
ok <? $i = 1; while ($i <= 5) echo $i++ ."<br>"; ?>
ok <? $i = 1; while ($i <= 5) { echo $i++ ."<br>"; } ?>
ok <? $i = 1; ?> <? while ($i <= 5) { ?> <? echo $i; ?> <? echo "<br>"; ?> <? $i = $i + 1; ?> <? } ?>
no <? while (true) { if ($i >= 5) break; else print $i++ . "<br>"; } ?>
no <? $s = "1,2,3,4,5"; $a = explode( ',', $s); $i=1; do { echo $a[$i++]."<br>"; } while ($i < 5); ?>
no <? do { echo $i++."<br>"; } while ($i < 5); ?>
ok <? do { echo $i++."<br>"; if($i > 5) break; } while (true); ?>