PHPÑ»·Óï¾ä
Ñ»·Óï¾äÊÇ ÎªÁ˽â¾ö±à³ÌÖÐ "ÐèÒªÖØ¸´Ò»¶ÎÖ¸ÁîÖ±µ½Âú×ãÌØ¶¨Ìõ¼þΪֹ" µÄÒ»ÖÖÑ»·»úÖÆ
1¡¢while
whileÓï¾äÖ¸¶¨ÁËÒ»¸öÌõ¼þ£¬ÔÚÆäǶÈë´úÂë½áÊøÖ´ÐÐǰ£¬±ØÐëÂú×ãÕâ¸öÌõ¼þ¡£
Óï·¨£º
while(expression){
statements
}
example:
<?php
$count = 1;
while($count<5){
echo "$count squared = ".pow($count,2)."<br/>";
$count++;
}
?>
ÓëËùÓÐÆäËü¿ØÖƽṹһÑù£¬ÔÚwhile Óï¾äÖпÉÒÔǶÈë¶à¸öÌõ¼þ±í´ïʽ
<?php
$linecount = 1;
$fh = fopen("sports.txt",r);
while(!feof($fh) && $linecount <= 5){
$line = fgets($fh,4096);
echo $line."<br/>";
$linecount++;
}
?>
2¡¢do ... while
do ... whileÑ»·Ìõ¼þÊÇwhileµÄÒ»ÖÖ±äÌå,ËüÔÚ´úÂë¿éµÄ½áÊø´¦Ñé֤ѻ·Ìõ¼þ£¬¶ø²»ÊÇÔÚ¿ªÊ¼´¦¡£
Óï·¨:
do{
statements
}while(expression)
whileºÍdo...whileÔÚ¹¦ÄÜÉÏÏàËÆ£»Î¨Ò»µÄÇø±ðÔÚÓÚwhileÓï¾äÖеĴúÂë¿é¿ÉÄÜÓÀÔ¶²»Äܱ»Ö´ÐУ¬¶ødo...whileÓï¾äÖеĴúÂë¿é×ÜÊÇÖÁÉÙ»áÖ´ÐÐÒ»´Î¡£¿¼ÂÇÈçÏÂÀý×Ó£º
<?php
$count = 11;
do{
Ïà¹ØÎĵµ£º
PHP5ÖÐʹÓÃparent::À´ÒýÓø¸ÀàµÄ·½·¨¡£ parent:: ¿ÉÓÃÓÚµ÷Óø¸ÀàÖж¨ÒåµÄ³ÉÔ±·½·¨¡£parent::µÄ×·Ëݲ»½öÓÚÖ±½Ó¸¸Àà¡£
ͨ¹ýparent::µ÷Óø¸Àà·½·¨
<!-- ÉùÃ÷Ò»¸öÔ±¹¤Àà,¾ÀíÀà¼Ì³Ð×ÔÔ±¹¤Àà -->
<?php
class employee
{
protected $sal = 3000;
public function getSal() {
$this->sal = $this-> ......
µ¥¼þģʽҪ½â¾öµÄÎÊÌâ¾ÍÊÇ“ÈçºÎÈÃÕâ¸öÀàÖ»ÓÐÒ»¸öʵÀý”¡£
ÎÒÃǵÄwebÓ¦ÓÃÖУ¬´óÁ¿Ê¹ÓÃÁËÊý¾Ý¿âÁ¬½Ó£¬Èç¹û·´¸´½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó±ØÈ»ÏûºÄ¸ü¶àµÄϵͳ×ÊÔ´¡£
ÎÒÃÇÈçºÎ½â¾öÕâ¸öÎÊÌ⣬½¨Á¢Î¨Ò»µÄÊý¾Ý¿âÁ¬½ÓÊDZØÒªµÄ·½Ê½¡£
ÎÒÃÇÓÖÈçºÎÖªµÀÓëÕâ¸öÊý¾Ý¿âµÄÁ¬½ÓÊÇ·ñÒѾ½¨Á¢£¿ »¹ÊÇÐèÒªÏÖÔÚ½¨Á¢£¿
µ¥¼þģʽ¿ÉÒÔ½â¾öÕ ......
Ò»¸ö½Ó¿Ú¿ÉÒԼ̳Ð×ÔÁíÍâµÄ½Ó¿Ú¡£PHP5ÖеÄÀàÊǵ¥¼Ì³Ð£¬µ«ÊǽӿںÜÌØÊâ¡£Ò»¸ö½Ó¿Ú¿ÉÒԼ̳Ð×Ô¶à¸ö½Ó¿Ú¡£
Ò»¸ö½Ó¿Ú¼Ì³ÐÆäËü½Ó¿Úʱºò£¬Ö±½Ó¼Ì³Ð¸¸½Ó¿ÚµÄ¾²Ì¬³£Á¿ÊôÐԺͳéÏó·½·¨¡£
ÔÚPHP5ÖУ¬½Ó¿ÚÊÇ¿ÉÒԼ̳Ð×ÔÁíÍâÒ»¸ö½Ó¿ÚµÄ¡£ÕâÑù´úÂëµÄÖØÓøüÓÐЧÁË¡£
ҪעÒâÖ»ÓнӿںͽӿÚÖ®¼äʹÓà ¼Ì³Ð¹Ø¼ü×Öextends¡£
ÀàʵÏÖ½Ó¿Ú±ØÐëʵÏÖ ......
Ò»¡¢¹æ·¶Ç°ÑÔÆª
±ê×¼»¯²»ÊÇÌØÊâµÄ¸öÈË·ç¸ñ£¬ËüÈóÌÐòÔ±¿ÉÒÔÁ˽âÈκδúÂ룬ŪÇå³ÌÐòµÄ×´¿ö£»ÐÂÈË¿É
ÒԺܿìµÄÊÊÓ¦»·¾³£»·ÀֹнӴ¥phpµÄÈËÒ»´Î´ÎµÄ·¸Í¬ÑùµÄ´íÎó£»ÔÚÒ»ÖµĿª·¢»·¾³Ï£¬
¿ÉÒÔ¼õÉÙÈËÃÇ·¸´íµÄ»ú»á¡£±¾¹æ·¶µÄ±ê×¼ÔÚ¾ø¶Ô¶àÊýÓ¦ÓÃÉÏΪ·ÂÕÕjava¼¼ÊõÌåϵ£¬ÒòΪ
java¼¼ÊõÌåϵÒÔÆäÖÚ¶à³É¹¦µÄ°¸Àý³ÉΪ´ó²¿·Ö¼ÆËã»úÓ¦Ó ......