¡¾×ª¡¿PHP & Web Service[³õ¼¶]
Ç°ÑÔ
¡¡¡¡
¡¡¡¡·Ï»°²»¶à˵£¬WebServiceÕâ¸öÈÈ°¡£¬PHPÕâ¸ö»ð°¡£¬ÏëÓÃPHP¿ª·¢WebServiceÊÇÀíËùµ±È»µÄÊ¡£Ê²Ã´£¿²»¶®WebService£¿Ã»Ê£¬°Ù¶ÈһϾÍÖªµÀÁË¡£°¡£¿¿´²»¶®£¿²»¶®Ò²Ã»¹Øϵ£¬Ö±½Ó¿´´óÉÙүдµÄ°É£º£©
¡¡¡¡´óÉÙÒ¯ÊǸö¼¤½ø·Ö×Ó£¬Ï²»¶Ö±½ÓÄôúÂë˵Ê£¬²»¹ýÔÚ°Ñ¿ÉÁ¯µÄ¶ÁÕßŪµÃһͷÎíˮ֮ǰ£¬»¹ÊÇÏÈ´óÖÂ˵һϱ¾ÎĵÄÄ¿µÄ¡£±¾ÎIJ»´òËã½²ÊöWebServiceµÄ¸ÅÄҲ²»´òËã½²ÄÇЩ¸´ÔÓµÄÐÒéÄÚÈÝ¡£±¾ÎÄÖ»ÊÇÒªÈôó¼Ò¿´¿´¶ÔÓÚWebService£¬PHP¿ÉÒÔ×öЩʲô£¬Ôõô×ö£¬ÓÐʲôҪעÒâµÄ¡£
¡¡¡¡
¡¡¡¡Èç¹ûÄã¸Õ²ÅÌýÁË´óÉÙÒ¯µÄ²éÁ˰ٶȣ¬»òÕßÄãÒÔÇ°²é¹ý£¬ÄãÓ¦¸ÃÒѾ´ó¸ÅÖªµÀÁËWebServiceµÄÓô¦¡£Í¨¹ýWebService£¬ÎÒÃÇ¿ÉÒÔµ÷Óò¿ÊðÔÚÆäËûµØ·½µÄ³ÌÐò£¬¶ø²»ÓÃcare±»µ÷ÓõijÌÐòÊÇÔÚʲôƽ̨ÓÃʲôÓïÑÔ±àдµÄ¡£Ò²ÐíÄãÌý˵¹ýGoogleAPI¡¢YahooAPIʲôµÄ£¬´óÉÙÒ¯ËäȻûÓа¤¸öµ÷²é¹ý£¬µ«ÖªµÀÖÁÉÙgoogleÊÇ×ñÕÕ±ê×¼µÄWeb ServiceʵÏֵģ¬googleÓõÄÊÇjava£¬ÎÒÃÇÕâÀォʹÓÃPHP¡£
¿ªÊ¼£ºHello Word!
¡¡¡¡ÏÈÀ´¿´´úÂ룺
<?php
/**
* ʵÏÖÒµÎñÂß¼µÄÀ࣬´ËÀàÊÇÒ»¸öÆÕͨÀà
*
*/
class Basic {
/**
* ·µ»ØÒ»¸ö×Ö·û´®£ºHello World!
*
* @return string
*/
public function returnString(){
return "Hello World!";
}
}
?>
¡¡¡¡so¼òµ¥£¬Ò»¸öÀ࣬·µ»ØÒ»¸ö×Ö·û´®¡£¼ÙÉèÕâ¸ö³ÌÐòÔÚ·þÎñÆ÷AÉÏÃ棬Èç¹û´óÉÙÒ¯ÏëÔÚ·þÎñÆ÷BÉÏÃæÏëµ÷ÓÃÕâ¸ö³ÌÐòÔõô°ì£¿Ê×ÏÈÎÒÃÇÏÈÒª½«Õâ¸öÀà±ä³ÉWeb·þÎñ£¬Õâ¾ÍÐèҪʹÓÃPHPµÄSOAPÀ©Õ¹£¬ÈçºÎ°²×°Õâ¸öÀ©Õ¹Çë²Î¿¼PHPÊֲᡣ°²×°ºÃºó£¬Çë¿´ÈçÏ´úÂë¡£
<?php
/**
* Web ServiceµÄServer¶Ë£¬°üº¬ÀàÎļþ¡£
*/
require_once("Basic.php");
/**
* ´´½¨Server¶ÔÏó
*/
$arrOptions = array('uri'=>'http://example.com/'); //ÉèÖÃÃüÃû¿Õ¼ä
$objSoapServer = new SoapServer(null,$arrOptions);
/**
* ×¢²áBasicÀàµÄËùÓз½·¨
*/
$objSoapServer->setClass("Basic");
/**
* ´¦ÀíÇëÇó
*/
$objSoapServer->handle();
?>
¡¡¡¡OK£¬Ò»¸öWeb·þÎñ´î½¨ºÃÁË£¬ÉÏÃæµÄÀý×ÓÖУ¬ÎÒÃÇ´´½¨ÁËÒ»¸öSoapServer¶ÔÏó£¬È»ºóÀûÓÃsetClassº¯Êý½«ÎÒÃǸղűàдµÄBasicÀàset½øÈ¥£¬×îºóhandle()£¬ÄǸöÃüÃû¿Õ¼äÎÒÃÇÏȲ»È¥¹ÜËü¡£ÏÖÔÚÈç¹ûÓÃä¯ÀÀÆ÷·ÃÎÊÕâ¸öÎļþ£¬»á³öÏÖ¾¯¸æ£¬ÕâÊÇÕý³£µÄ£¬ÒòΪÕâ¸öÎļþ²»ÊÇÓÃä¯ÀÀÆ÷·ÃÎʵģ¬¶
Ïà¹ØÎĵµ£º
http://blog.s135.com/read.php/142.htm
¡¡¡¡×î½üÔÚдPHP³ÌÐòʱ£¬ÐèҪʹä¯ÀÀÆ÷ÔÚhttpsºÍhttpÖ®¼äת»¯£¬ÉÏÍøËÑË÷Ïà¹ØÐÅÏ¢£¬ÎÞÄÎÖ»ÓÐ×î½üÔÚдPHP³ÌÐòʱ£¬ÐèҪʹä¯ÀÀÆ÷ÔÚhttpsºÍhttpÖ®¼äת»¯£¬ÉÏÍøËÑË÷Ïà¹ØÐÅÏ¢£¬ÎÞÄÎÖ»ÓÐһƪ½éÉÜÓÃASPʵÏÖ“ÔÚhttpºÍhttpsÖ®¼äת»¯”µÄÎÄÕ£¬ÓÚÊÇÖ»ºÃÐÐдÁËÓÃPHPʵÏÖhttpÓëhttpsת» ......
phpÒýÓÃ(&)Ïê½â
2009-05-13 14:30
phpµÄÒýÓ㨾ÍÊÇÔÚ±äÁ¿»òÕߺ¯Êý¡¢¶ÔÏóµÈÇ°Ãæ¼ÓÉÏ&·ûºÅ£©
ÔÚPHP ÖÐÒýÓõÄÒâ˼ÊÇ£º²»Í¬µÄÃû×Ö·ÃÎÊͬһ¸ö±äÁ¿ÄÚÈÝ.
Óë£ÃÓïÑÔÖеÄÖ¸ÕëÊÇÓвî±ðµÄ£®£ÃÓïÑÔÖеÄÖ¸ÕëÀïÃæ´æ´¢µÄÊDZäÁ¿µÄÄÚÈÝÔÚÄÚ´æÖдæ·ÅµÄµØÖ·
±äÁ¿µÄÒýÓÃ
PHP µÄÒýÓÃÔÊÐíÄãÓ ......
If...Else Óï¾ä
if¡¢elseif ÒÔ¼° else Óï¾äÓÃÓÚÖ´ÐлùÓÚ²»Í¬Ìõ¼þµÄ²»Í¬¶¯×÷¡£µ±Äú±àд´úÂëʱ£¬Äú³£³£ÐèҪΪ²»Í¬µÄÅжÏÖ´Ðв»Í¬µÄ¶¯×÷¡£Äú¿ÉÒÔÔÚ´úÂëÖÐʹÓÃÌõ¼þÓï¾äÀ´Íê³É´ËÈÎÎñ£º
if...else Óï¾ä
ÔÚÌõ¼þ³ÉÁ¢Ê±Ö´ÐÐÒ»¿é´úÂ룬Ìõ¼þ²»³ÉÁ¢Ê±Ö´ÐÐÁíÒ»¿é´úÂë
elseif Óï¾ä
Óë if...el ......
Ñ»·Óï¾ä
ÔÚÄú±àд´úÂëʱ£¬Äú¾³£ÐèÒªÈÃÏàͬµÄ´úÂë¿éÔËÐкܶà´Î¡£Äú¿ÉÒÔÔÚ´úÂëÖÐʹÓÃÑ»·Óï¾äÀ´Íê³ÉÕâ¸öÈÎÎñ¡£
ÔÚ PHP ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁÐÑ»·Óï¾ä£º
while
Ö»ÒªÖ¸¶¨µÄÌõ¼þ³ÉÁ¢£¬ÔòÑ»·Ö´ÐдúÂë¿é
do...while
Ê×ÏÈÖ´ÐÐÒ»´Î´úÂë¿é£¬È»ºóÔÚÖ¸¶¨µÄÌõ¼þ³ÉÁ¢Ê±Öظ´Õâ¸öÑ»·
for
Ñ»·Ö´ÐдúÂë¿éÖ¸¶¨µÄ´ÎÊý
foreach
¸ù ......
±íµ¥ºÍÓû§ÊäÈë
PHP ±íµ¥´¦Àí
±íµ¥ÊµÀý£º
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html> ......