PHP×Ö·û´®ÖеĴóÀ¨ºÅ
<?php
class Model_Data_FocusData{
....
public function getData(){...}
}
class Model_Data_IndexData{
....
public function getData(){...}
}
?>
ÓÐÕâô¼¸¸öÀ࣬ϣÍûÄܹ»×Ô¶¯µÄ¸ù¾Ý²ÎÊýÀ´µ÷Óò»Í¬µÄÀà´¦ÀíÊý¾Ý¡£
¿´µ÷ÓÃÄ£¿é£º
<?php
function getData($act){
$class = "Model_Data_{$act}Data";
$model = new $class();
return $model->getData();
}
?>
Õâ¸ö¿é¿´ÆðÀ´Ã»ÓÐÒ»µãÎÊÌ⣬ÔÚWAMPÏÂÔËÐÐҲûÓÐÎÊÌâ¡£
µ«ÊÇÒÆÖ²µ½LAMPºó£¬·¢ÏÖÖ´Ðе½ÕâÒ»¶Î´úÂëµÄʱºòÖжÏÁË¡£
ÎÊÌâÔÚÄÄÀïÄØ£¿
$class = "Model_Data_{$act}Data";
$model = new $class();
¿´ÕâÀ"Model_Data_{$act}Data"; »»³É "Model_Data_".$act."Data";ºó£¬Õâ¶Î´úÂëÓÖͨ¹ýÁË¡£
Óɴ˵óö½áÂÛ£º
php×Ö·û´®ÖмÓÈë´óÀ¨ºÅÒýÓñäÁ¿Ê±£¬²¢Ã»ÓÐÁ¢¼´´¦Àí¸Ã±äÁ¿£¬¶øÊÇ×îÖÕʹÓõÄʱºò´¦Àí£¬±ÈÈ磺echoµÄʱºò£¬echoÕâ¸öÃüÁî¾ßÓнâÎö×Ö´®ÖбäÁ¿¹¦ÄÜ£¬¶ø new ¹Ø¼ü´ÊÏÔÈ»²»¾ß±¸¡£
Ïà¹ØÎĵµ£º
<?php
header("Content-type:text/html;charset=gb2312"); //¿´ÄãÓõÄÊÇʲô±àÂ룬Ҫ±£³ÖÒ»Ö¡£
$files="config.php"; //ҪдÈëµÄÅäÖÃÎļþ¡£
if(!is_writable($files)){ //ÅжÏÊÇ·ñÓпÉдµÄȨÏÞ£¬linux²Ù×÷ϵͳҪעÒâÕâÒ»µã£¬windows²»±Ø×¢Òâ¡£
echo "<font color=red>Îļþ²»¿Éд</font>";
......
Õ¾µã½á¹¹
´úÂë:
Õ¾µã
©»includes
©»class.inc
©Çtemplet
©»index.htm
©Çlist.htm
©»content.htm
©Çindex.php
©»content.php
¿â½ ......
±êÌâÓе㳤£¬Æäʵ¾ÍÊÇÓÃÀ´Ïòhttps·þÎñÆ÷postÊý¾Ý
function curlPost($url, $data, $timeout = 30)
{
$ssl = substr($url, 0, 8) == "https://" ? TRUE : FALSE;
$ch = curl_init();
$opt = array(
CURLOPT_URL => $url,
CURLOPT_POST => 1,
CURLOPT_ ......