PHP»ñµÃµÄ¿Í»§¶ËºÍ·þÎñÆ÷¶ËIP
¿Í»§¶ËIPÏà¹ØµÄ±äÁ¿
1. $_SERVER['REMOTE_ADDR']; ¿Í»§¶ËIP£¬ÓпÉÄÜÊÇÓû§µÄIP£¬Ò²ÓпÉÄÜÊÇ´úÀíµÄIP¡£
2. $_SERVER['HTTP_CLIENT_IP']; ´úÀí¶ËµÄIP£¬¿ÉÄÜ´æÔÚ£¬¿ÉαÔì¡£
3. $_SERVER['HTTP_X_FORWARDED_FOR']; Óû§ÊÇÔÚÄĸöIPʹÓõĴúÀí£¬¿ÉÄÜ´æÔÚ£¬¿ÉÒÔαÔì¡£
·þÎñÆ÷¶ËIPÏà¹ØµÄ±äÁ¿
1. $SERVER_NAME£¬ÐèҪʹÓú¯Êýgethostbyname()»ñµÃ¡£Õâ¸ö±äÁ¿ÎÞÂÛÔÚ·þÎñÆ÷¶Ë»¹Êǿͻ§¶Ë¾ùÄÜÕýÈ·ÏÔʾ¡£
2. $HTTP_SERVER_VARS["SERVER_ADDR"]£¬ÔÚ·þÎñÆ÷¶Ë²âÊÔ£º127.0.0.1£¨Õâ¸öÓëhttpd.confÖÐBindAddressµÄÉèÖÃÖµÏà¹Ø£©¡£ÔÚ¿Í»§¶Ë²âÊÔ½á¹ûÕýÈ·¡£
3. $_SERVER['LOCAL_ADDR'] ¡¢$HTTP_SERVER_VARS['LOCAL_ADDR']£¬²âÊÔÖУ¬Î´»ñµÃÈκνá¹û£¨²âÊÔ»·¾³PHP5£©¡£
ÍêÕûµÄ»ñµÃIPÀà
class getIP{
function clientIP(){
$cIP = getenv('REMOTE_ADDR');
$cIP1 = getenv('HTTP_X_FORWARDED_FOR');
$cIP2 = getenv('HTTP_CLIENT_IP');
$cIP1 ? $cIP = $cIP1 : null;
$cIP2 ? $cIP = $cIP2 : null;
return $cIP;
}
function serverIP(){
return gethostbyname($_SERVER_NAME);
}
}
$getIP = new getIP();
$clientIp = getIP::clientIP();
$serverIp = getIP::serverIP();
echo 'Client IP is ',$clientIp,'<br />';
echo 'Server IP is ',$serverIp,'<br />';
Ïà¹ØÎĵµ£º
1.»ù±¾Àà
//smarty_config.php
<?php
define('TEMPLATE_DIR','templates/');
define('COMPILE_DIR','templates_c/');
define('CONFIG_DIR','configs/');
define('CACHE_DIR','cache/');
?>
//View.class.php
<?php
//ÅäÖÃÎļþ
require_once 'configs/smart_config.php';
//SmartyÀà
require('smarty/ ......
phpµÄº¯Êý·ÖΪϵͳº¯Êý£¬Óû§º¯Êý
1£¬phpº¯Êý²»Çø·Ö´óСд
º¯ÊýÔÐÍ£º
·µ»ØÀàÐÍ º¯ÊýÃû³Æ£¨ÀàÐÍ ²ÎÊý£©
2.1£¬ÏµÍ³º¯ÊýÖг£ÓõÄÊýѧº¯Êý
abs(eumber) È¥¾ø¶ÔÖµ
sin(float) ÕýÏÒ¼ÆËãsin(x)
cos(float) ÓàÏÒ¼ÆËãcos(x)
log(float) ×ÔÈ»¶ÔÊý¼ÆËã
sqrt(float) ¿ªÆ½·½¸ù¼ÆËã
log10(float) 10»ùµ×µÄ¶ÔÊý
ex ......
index.php:
$smarty = new Smarty;
$smarty->assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
$smarty->display('index.tpl');
index.tpl:
{$Contacts[0]}<br>
{$Contacts[1]}<br>
{* you can print arrays of arrays ......
test.php´úÂ룺 view plaincopy to clipboardprint?
assign("total",$total); //¶ÔÄ£°æÖеıäÁ¿¸³Öµ $formatted_total = number_format($total); //¸ñʽ»¯$total $smarty->assign("formatted_total",$formatted_total); //¶ÔÄ£°æÖеıäÁ¿¸³Öµ $smarty->display('test1.htm'); //ÏÔÊ¾Ò³Ãæ ?>
assign("total",$t ......
×ÛºÏÍøµêϵͳÊÇÓÉEÒ×ÍøÂç(68ws.cn)»ùÓÚphp+mysql¿ª·¢£¬¼æÈݸ÷ÀàÉÌÆ·µÄ·¢²¼¡¢Õ¹Ê¾ºÍ¶©¹º¡£³ýÁ˾ßÓÐÍêÉÆµÄÉÌÆ·ÀàÐ͹ÜÀí¡¢ÉÌÆ·¹ÜÀí¡¢ÅäËÍÖ§¸¶¹ÜÀí¡¢¶©µ¥¹ÜÀí¡¢»áÔ±·Ö×é¡¢»áÔ±¹ÜÀí¡¢²éѯͳ¼ÆºÍ¶àÏîÉÌÆ·´ÙÏú¹¦ÄÜ£¬»¹¾ßÓÐÍêÕûµÄÎÄÕ¡¢Í¼ÎÄ¡¢ÏÂÔØ¡¢µ¥Ò³¡¢¹ã¸æ·¢²¼µÈÍøÕ¾ÄÚÈݹÜÀí¹¦ÄÜ¡£ÏµÍ³¾ßÓо²Ì¬HTMLÉú³É¡¢UTF-8¶àÓïÑÔÖ§³ ......