ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

5-3 ¸ê®Æ¿é¥X(5-3-1 echo()¨ç¼Æ)

5-3 ¸ê®Æ¿é¥X(5-3-1 echo()¨ç¼Æ)

5-3   ¸ê®Æ¿é¥X
¦b«e­±³¹¸`¤¤¡A­n¿é¥X¸ê®Æ¨ìºô­¶µe­±¤¤¡Aµ§ªÌ¨Ï¥Î¤Fecho()¨ç¼Æ¡A¥i¬Oµ§ªÌ¤S¨Ï¥Î¤F«Ü¦h¤£¦Pªº®æ¦¡¡A±z¥i¯à§Ë±o¤@¹ÎÃú¤ô¡A©Ò¥H¥»³¹¸`±N»¡©ú¤@¤U¡A¤S¡A°£¤Fecho()¨ç¼Æ¥i¿é¥X¸ê®Æ¨ìºô­¶µe­±¤¤¥~¡AÁÙ¦³´X­Ó¨ç¼Æ¤]¦³¸ê®Æ¿é¥Xªº¥\¯à¡A³o¨Ç¨ç¼Æ§Ú­Ì¤]­n»{ÃѤ@¤U¡C



5-3-1   echo()¨ç¼Æ
echo()¨ç¼Æ­t³d±N¦r¦ê¸ê°T¿é¥X¦Ü¨Ï¥ÎªÌºÝ¡A¤]¥i»PHTML¼Ð¥Ü²V¦X¨Ï¥Î¡A¼Ð·Ç®æ¦¡¦p¤U¡G
¼Ð·Çecho()¨ç¼Æ®æ¦¡
  1. echo ( string arg1 [, string argn...]);
½Æ»s¥N½X
¨Ò¦p¡G
  1. <?
  2. echo (¡§³o¬O¥ÑPHP¿é¥Xªº¤å¦r¡¨);
  3. ?>
½Æ»s¥N½X
¬Ý¨ì¤F§a¡I¼Ð·Çªºecho()¨ç¼Æ¥Îªk¬O±N¦r¦ê¤º®e¥Î¤@²Õ¬A¸¹¥]°_¨Ó¡A¦Ó­n¿é¥Xªº¦r¦ê¦A¥Î¤@¹ïÂù¤Þ¸¹¬A°_¨Ó¡A¦]¬°echo()¨ç¼Æ¬O¥Î¨Ó¿é¥X¦r¦ê¸ê®Æªº¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¦n²Ö³á¡I¤S¬O¬A¸¹¤S¬OÂù¤Þ¸¹ªº¡A¶û³Â·Ð£«¡A¨º¦n¡A§Ú­Ì§â³Ì¥~­±ªº¬A¸¹®³±¼¡A³o¼Ë¤]¦æ¡G
  1. <?
  2. echo ¡§³o¬O¥ÑPHP¿é¥Xªº¤å¦r¡¨;
  3. ?>
½Æ»s¥N½X
¥i¬O¡A§Ú¦³¯S©wªºÅܼƭȭn¸ò¦r¦ê¤@°_¿é¥X­C¡I¨SÃö«Y¡I§Ú­Ì¥Î¡u.¡v¤p¶ÂÂI§â¥¦³s°_¨Ó¡A¡u.¡v¤p¶ÂÂI«e«á­n¥[ªÅ®æ¡]space¡^³á¡I±z¤£¥Î¾á¤ß³o­ÓªÅ®æ¡Aecho()¨ç¼Æ¦b¿é¥X¸ê®Æ®É·|©¿²¤±¼³o¨ÇªÅ®æ¡G
  1. <?
  2. $x="PHP";
  3. echo "³o¬O¥Ñ" . $x . "¿é¥Xªº¤å¦r";
  4. ?>
½Æ»s¥N½X
±z¤S¶û³Â·Ð¤F³á¡I¨SÃö«Y¡I§â¡u.¡v¤p¶ÂÂI®³±¼§a¡I±NÅܼƸò¦r¦ê¥þ³¡©ñ¦bÂù¤Þ¸¹¤¤´N¦n¡G
  1. <?
  2. $x="PHP";
  3. echo "³o¬O¥Ñ$x ¿é¥Xªº¤å¦r";
  4. ?>
½Æ»s¥N½X
¦b¤W¨Ò¤¤¡AÅܼƪº$¦r¤¸«e¥i¥H¤£¥[ªÅ®æ¡A¦ý¬OÅܼƦWºÙ«á­n¥[­ÓªÅ®æ¡A¤£µMPHP·|§â¡u$x¿é¥Xªº¤å¦r¡v·í¦¨¬O¤@­ÓÅܼơA¦Ó³y¦¨µ{¦¡¿ù»~¡A¤£¹L¡A³o­ÓªÅ®æecho()¨ç¼Æ¦b¿é¥X¸ê®Æ®É¤£·|©¿²¤±¼¡A·|©Þ¥¦·í¦¨¬O¦r¦êªº¤º®e¡C
¨º§Ú­n¦P®É¦L¥XÅܼƦWºÙ¸òÅܼƭȮɸӦp¦ó°µ¡H­n¦L¥XÅܼƦWºÙ«h¥²¶·©óÅܼƪº¡u$¡v¤§«e¥[¤W¤Ï±×½u¡u\¡v¡A­ì¦]¦b©ó¡u$¡v¬°¤@­Ó²æ¶h¦r¤¸¡A¥Î¨ÓÃѧOÅܼơG
  1. <?
  2. $x="PHP";
  3. echo " $x ";   //¦L¥XÅܼƭȡ¨PHP¡¨
  4. echo " \$x ";  //¦L¥XÅܼƦWºÙ¡¨$x¡¨
  5. ?>
½Æ»s¥N½X
­Y­n±NHTML¼ÐÅÒ¥[¤Jecho()¨ç¼Æªº¿é¥X¸ê®Æ®É¡A¦]¬°HTML¼ÐÅÒªºÄݩʳ]©w­È¦h·|¥HÂù¤Þ¸¹¬A°_¨Ó¡A¦Ó³o­ÓÂù¤Þ¸¹¤S¬OPHPªº²æ¶h¦r¤¸¤§¤@¡A©Ò¥H¡A¤d¸U§O§Ñ¤F¦b¡u¡¨¡v¤§«e¥[¤W¤Ï±×½u¡u\¡v¡G
ex05_07.php
  1. <html>
  2. <head>
  3. <title>ex05_07</title>
  4. </head>
  5. <body>
  6. ¤j®a¨Ó¾ÇPHP
  7. <hr>
  8. ¤µ¤Ñ¬O:
  9. <?echo "<font color=\"#FF0000\">" . date("Y¦~m¤ëj¤é");?>
  10. </body>
  11. </html>
½Æ»s¥N½X
¤W¨Ò°õ¦æµ²ªG¦p¤W¹Ï5-15©Ò¥Ü¡A§Ú­Ì¥i¥H«Ü²M·¡ªº¬Ý¨ìPHPºô­¶°õ¦æ«áªºµe­±¡A§Ú­Ì§Q¥Î¡yecho()¡z¤èªk¿é¥X¤F¤@­Ó¤é´Á¸ê®Æ¡A¦Ó³o­Ó³o­Ó¤é´Á¦r¦ê§Ú­ÌÁÙ¥[¤W¤FHTML¼ÐÅÒ¡u<font color="#FF0000">¡v¨Ó³]©w¥¦ªº¤å¦rÃC¦â¡A°ÝÃD¬O¼ÐÅÒ¤º¨Ï¥Î¤FÂù¤Þ¸¹¡A¦b¡u¡¨¡v¤§«e¥[¤W¦A¥[¤W¤Ï±×½u¡u\¡v¡C
0.png
¹Ï5-15  ½d¨Òex05_07.php¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¦pªG§Ú³ßÅw±N¤£·|Åܰʪººô­¶¸ê®Æ¤]§Q¥Îecho()¨ç¼Æ¨Ó½s¼g¡A¥i¤£¥i¥H©O¡H·íµM¤]¥i¥H¡I¦ý¬O¡A³o¼Ë´NÅܦ¨½s¼g¤@¤ä§¹¾ãªºPHPµ{¦¡¤F¡A©Ò¥H¥þ³¡ªº±Ô­z³£¥²¶·©ñ¦b ¡y<? ¡z»P¡y?>¡z¤§¤¤¡A¦P®É¡A©Ò¦³ªºHTML¼ÐÅÒ³£¥²¶·¼g¦bÂù¤Þ¸¹ ¡y " ¡z¤§¤¤:
ex05_08.php
  1. <?
  2. echo "<html>";
  3. echo "<head>";
  4. echo "<title>ex05_08</title>";
  5. echo "</head>";
  6. echo "<body>";
  7. echo "¤j®a¨Ó¾ÇPHP";
  8. echo "<hr>";
  9. echo "¤µ¤Ñ¬O:";
  10. echo "<font color=\"#FF0000\">" . date("Y¦~m¤ëj¤é");
  11. echo "</body>";
  12. echo "</html>";
  13. ?>
½Æ»s¥N½X
¤W¨â­Ó½d¨Òªº¼gªk¡A¨äµ²ªG¬O¬Û¦Pªº¡Aµ§ªÌ­Ó¤H¤ñ¸û³ßÅw²Ä¤@ºØHTML¼ÐÅÒ¸ê®Æ²V¦X¼gªº¤è¦¡¡A¦Ü¤Ö¤£¥Î¥´¨º»ò¦h¦r¡A¤£¹L¡A¦³«e½ú«ü¥X¡AHTML¼ÐÅÒ¸ê®Æ²V¦X¼gªº¤è¦¡¦b°õ¦æ®Ä²v¤W¸û®t¡A¦]¬°¨t²Î·|¦bHTML¸ÑªR»PPHP Engine«ùÄò¤Á´«¡A¦p¦ó¦b¶}µo®É¶¡»P¨t²Î°õ¦æ®Ä²v¶¡¨ú±Ë´N¬Ý±zÅo¡I
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

²¤Æecho()¨ç¼Æ±Ô­z
¦b«e­±´X­Ó³¹¸`¡Aµ§ªÌ³£¨S¦³¨Ï¥Î²¤Æªº¿é¥X±Ô­z¡A¥¦ªº¥ÎªkÃþ¦üASPªº¡u<%=XXX%>¡v±Ô­z¼gªk¡A¨Ò¦p¡G
  1. <?echo date("Y¦~m¤ëj¤é");?>
  2. <?=date("Y¦~m¤ëj¤é")?>
½Æ»s¥N½X
¤W¨Òªº¨â¦æµ{¦¡±Ô­z°õ¦æµ²ªG³£¬O¤@¼Ë¦a¡A«áªÌ¦ü¥G¤ñ¸û²©ú¹ï§a¡I¦ý¬O¡A²¤Æªº¡u<?=XXX?>¡v ±Ô­z¥u¯à¦b³æ¦æ±Ô­z¯à¥Î³á¡I¦b±Ô­z°Ï¶ô¤¤¬O¤£¯à¥Îªº¡A¨Ò¦p¤U¨Ò¡G
  1. <?
  2. echo "¤j®a¨Ó¾ÇPHP";
  3. echo "<hr>";
  4. ="¤µ¤Ñ¬O:"
  5. echo "<font color=\"#FF0000\">" . date("Y¦~m¤ëj¤é");
  6. ?>
½Æ»s¥N½X
¦pªG±N¡u="¤µ¤Ñ¬O:"¡v³o¦æ±Ô­z¿W¥ß¥Î¤@²Õ¡u<? ?>¡v¬A°_¨Ó´N¥i¥H¤F¡G
  1. <?
  2. echo "¤j®a¨Ó¾ÇPHP";
  3. echo "<hr>";
  4. ?>
  5. <?="¤µ¤Ñ¬O:"?>
  6. <?
  7. echo "<font color=\"#FF0000\">" . date("Y¦~m¤ëj¤é");
  8. ?>
½Æ»s¥N½X
«¢¡I³o¼Ë¦n¹³¦³ÂIµe³D²K¨¬¡Iµ§ªÌ«Øij¡G¦bµ{¦¡°Ï¶ô¤¤§@¿é¥X´N¨Ï¥Î§¹¾ãªºecho()¨ç¼Æ±Ô­z¡A­Y¬O¦b»PHTML¼ÐÅÒ¸ê®Æ²V¦Xªº³õ¦X¤~¨Ï¥Î¡u<?=XXX?>¡vªº±Ô­z¼gªk¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¡i°µ¤Hªº¶}©l¡j¨C¤@¤Ñ³£¬O¬G¤Hªº¶}©l¡A¨C¤@­Ó®É¨è³£¬O¦Û¤vªºÄµ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD