php¼ì²âajax·½Ê½µÄµ÷ÓÃÇëÇó
±ÈÈçÒª¸øÓû§±¨¸æÒ»¸ö´íÎó£¬ÓÃÏÂÃæµÄ·½·¨£º
ʹÓÃset_error_handlerÉèÖÃ×Ô¼ºµÄ´íÎó´¦Àíº¯Êý£¬ÔÚ±¨´íµÄµØ·½Ê¹ÓÃtrigger_error£¬ÔÚ×Ô¶¨ÒåµÄ´íÎó´¦Àíº¯ÊýÖиøÓû§ÏÔʾһ¸ö³ö´íÐÅÏ¢Ò³Ãæ¡£
µ«
ÊÇÈç¹ûµ÷ÓÃtrigger_errorµÄÕâ¸öÒ³ÃæÊDZ»Ò»´ÎajaxÇëÇó´¥·¢µÄ£¬ÄÇôajax·µ»Øºó½«µÃµ½Ò»´ó¶ÑÓÃÓÚÏÔʾ´íÎóµÄhtml´úÂë¡£¶øÒ»°ã
ajaxµ÷Óö¼»áÔ¼¶¨×Ô¼ºµÄ´íÎóÐÅÏ¢¸ñʽ£¬ËùÒÔºǫ́php´úÂëҪôʹÓÃÁ½ÖÖ²»Í¬µÄ±¨¸æ´íÎóµÄ·½Ê½£ºÒ»ÖÖ¸øajaxµ÷ÓÃÇëÇóʹÓã¬Ò»ÖÖ¸øÆÕͨµÄÒ³ÃæË¢ÐÂʹ
Óã¬ÒªÃ´Ê¹ÓÃͳһµÄ´íÎ󱨸æ¸ñʽ£¬ÔÚ±¨¸æµÄʱºòÅжÏÒ»ÏÂÕâÊÇÒ»¸öajaxµ÷ÓÃÇëÇó»¹ÊÇÒ»¸öÆÕͨµÄÒ³ÃæË¢ÐÂÇëÇó¡£
ÔÚphp´úÂëÖмì²âÊÇ·ñajaxµ÷ÓÃÇëÇóµÄ·½·¨ÊÇ£º
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// this is an ajax request
}
Õâ¸ö·½·¨À´×ÔÓÚgoogleËÑË÷£¬¾Ý˵ֻÊÊÓÃÓÚjQuery·¢³öµÄajaxÇëÇó¡£
Ïà¹ØÎĵµ£º
»¨Á˼¸¸öСʱµÄʱ¼äÑо¿Ò»Ï£¬·¢ÏÖ»¹ÊDZȽϺÃÓõģ¡
smarty¿ÉÒԺܺõؽ«Âß¼Óë±íÏÖ·ÖÀ룬ºǫ́³ÌÐòÔ±ºÍwebÇ°¶Ë¹¤³Ìʦ¸÷¸É¸÷µÄÊ£¬²»ÏñÒÔÇ°£¬php´úÂëºÍhtml´úÂëÔÓºÏÔÚÒ»Æ𣬺ǫ́³ÌÐòÔ±ºÍÇ°¶ËÇ°ÐòÔ±Ò»Æð·¢ì£¬ÒòΪËûÃǵļ¼ÄÜÒªÇó¸ü¸ßÁË£¬¶¼±ØÐëÒª¶®¶Ô·½µÄÓïÑÔ£¬ºÇºÇ£¡
ÍøÉϽéÉܵÄÅäÖÃÌ«¶ßàÂÁË£¬Ò²ÐíÊÇÀÏ°æ±¾µÄÔµ¹ÊµÄ£¬ÒòΪÎÒ ......
¡¡Ã¿¸öPHP³ÌÐòÔ±¶¼ÖªµÀPHPÓÐÇ¿´óµÄÕýÔò±í´ïʽ¹¦ÄÜ£¬ÎªÁËÒÔºóµÄ¹¤×÷·½±ã£¬ÎÒ´ÓÍøÉÏÕûÀíÁ˹ØÓÚÕýÔò±í´ïʽµÄ×ÊÁÏ£¬·½±ãÒÔºó¹¤×÷ʱµÄ½øÐÐ×ÊÁϲéÔÄ¡£
¡¡¡¡ÕýÔò±í´ïʽ(regular expression)ÃèÊöÁËÒ»ÖÖ×Ö·û´®Æ¥ÅäµÄģʽ£¬¿ÉÒÔÓÃÀ´¼ì²éÒ»¸ö´®ÊÇ·ñº¬ÓÐijÖÖ×Ó´®¡¢½«Æ¥ÅäµÄ×Ó´®×öÌæ»»»òÕß´Óij¸ö´®ÖÐÈ¡³ö·ûºÏij¸öÌõ¼þµÄ×Ó´®µÈ¡£ ......
±±¾©´óѧÈí¼þÓë΢µç×ÓѧԺ“¶à²ã´Î¡¢¶à·½Ïò¡¢¶àÁìÓò¡¢Ä£¿é»¯” µÄ¿ª·Åʽ¿Î³ÌÌåϵ£¬¾Êµ¼ù¼ìÑéÖ¤Ã÷£¬·Ç³£ÊÊÓÃÓÚÅàÑø“¶à²ã´Î¡¢ÊµÓÃÐÍ¡¢¸´ºÏ½»²æÐÍ¡¢¹ú¼Ê»¯”µÄÈí¼þÓë΢µç×ÓÈ˲š£ÎªÂú×ãÉç»áºÍÆóÒµ¶ÔÈ˲ŵÄÐèÇ󣬶ԸßÖÊÁ¿µÄ¼ÌÐø½ÌÓýÏîÄ¿µÄÐèÇ󣬱±¾©´óѧÈí¼þÓë΢µç×ÓѧԺ³ÉÁ¢Á˼ÌÐø½ÌÓýÖÐÐÄ£¬ÃæÏòÉ ......
ͨ³£ÎÒÃÇдһ¸öÀàÈçÏ£º
a.php
class A
{
public function __construct()
{
echo "hello world!";
}
}
page.php
require("a.php");
$a = new A();
ÎÒÃÇÊÇͨ¹ýÊÖ¹¤ÒýÓÃij¸öÀàµÄÎļþÀ´ÊµÏÖº¯Êý»òÕßÀàµÄ¼ÓÔØ
µ«Êǵ±ÏµÍ³±È½ÏÅÓ´ó£¬ÒÔ¼°ÕâЩÀàµÄÎļþºÜ¶àµÄʱºò£¬ÕâÖÖ·½Ê½¾ÍÏԵ÷dz ......
Ò»£º½á¹¹ºÍµ÷ÓÃ(ʵÀý»¯)£º
class className{} £¬µ÷Óãº$obj = new className();µ±ÀàÓй¹Ô캯Êýʱ£¬»¹Ó¦´«Èë²ÎÊý¡£Èç$obj = new className($v,$v2...);
¶þ£º¹¹Ô캯ÊýºÍÎö¹¹º¯Êý£º
1¡¢¹¹Ô캯ÊýÓÃÓÚ³õʼ»¯£ºÊ¹ÓÃ__construct()£¬¿É´ø²ÎÊý¡£
2¡¢µ«Îö¹¹º¯Êý²»ÄÜ´ø²ÎÊý£¨ÓÃÓÚÔÚÏúÈ¥Ò»¸öÀà֮ǰִÐÐһЩ²Ù×÷»ò¹¦ÄÜ£©¡£Îö¹¹º¯ÊýÓà ......