Home > php教程 > PHP源码 > body text

php常见问题和解决方法三接上

WBOY
Release: 2016-06-08 17:33:19
Original
998 people have browsed it
<script>ec(2);</script>

22:如何取得用户的真实IP


PHP代码:--------------------------------------------------------------------------------

 
function iptype1 () { 
if (getenv("HTTP_CLIENT_IP")) { 
   return getenv("HTTP_CLIENT_IP"); 

else { 
   return "none"; 


function iptype2 () { 
if (getenv("HTTP_X_FORWARDED_FOR")) { 
   return getenv("HTTP_X_FORWARDED_FOR"); 

else { 
   return "none"; 


function iptype3 () { 
if (getenv("REMOTE_ADDR")) { 
   return getenv("REMOTE_ADDR"); 

else { 
   return "none"; 


function ip() { 
$ip1 = iptype1(); 
  $ip2 = iptype2(); 
$ip3 = iptype3(); 
if (isset($ip1) && $ip1 != "none" && $ip1 != "unknown") { 
   return $ip1; 

elseif (isset($ip2) && $ip2 != "none" && $ip2 != "unknown") { 
   return $ip2; 

elseif (isset($ip3) && $ip3 != "none" && $ip3 != "unknown") { 
   return $ip3; 
}   
  else { 
  return "none"; 



Echo ip(); 
?> 
--------------------------------------------------------------------------------



23:如何从数据库读取三天内的所有记录

首先表格里要有一个DATETIME字段记录时间,
格式为'2003-7-15 16:50:00'

SELECT * FROM `xltxlm` WHERE TO_DAYS(NOW()) - TO_DAYS(`date`) 

24:如何远程链接Mysql数据库


在增加用户的mysql表里有一个host字段,修改为"%",或者指定允许连接的ip地址,这样,你就可以远程调用了。

$link=mysql_connect("192.168.1.80:3306","root","");


25:正则到底怎么用

点击这里
正则表达式中的特殊字符


26:用Apache后,主页出现乱码 


方法一: 
AddDefaultCharset ISO-8859-1 改为 AddDefaultCharset off 

方法二: 
AddDefaultCharset GB2312

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!