zoukankan      html  css  js  c++  java
  • 常用的函数整理1(ip,时间函数,二维码)


    function GetIP(){
    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
    $ip = getenv("HTTP_CLIENT_IP");
    else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
    $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
    $ip = getenv("REMOTE_ADDR");
    else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
    $ip = $_SERVER['REMOTE_ADDR'];
    else
    $ip = "unknown";
    return($ip);
    }

    // 调用方法 :昨日 $start= strftime( "%Y-%m-%d %H:%M:%S", $this->DateAdd('d',-1,time()) );
    function DateAdd ($interval, $number, $date) {
    $date_time_array = getdate($date);
    $hours = $date_time_array["hours"];
    $minutes = $date_time_array["minutes"];
    $seconds = $date_time_array["seconds"];
    $month = $date_time_array["mon"];
    $day = $date_time_array["mday"];
    $year = $date_time_array["year"];
    switch ($interval) {
    case "yyyy": $year +=$number; break;
    case "q": $month +=($number*3); break;
    case "m": $month +=$number; break;
    case "y":
    case "d":
    case "w": $day+=$number; break;
    case "ww": $day+=($number*7); break;
    case "h": $hours+=$number; break;
    case "n": $minutes+=$number; break;
    case "s": $seconds+=$number; break;
    }
    $timestamp = mktime($hours ,$minutes, $seconds,$month ,$day, $year);
    return $timestamp;}

    //二维码生成则可以参考 phpqrcode

  • 相关阅读:
    调用Android自带日历功能
    android使用全局变量传递数据
    安卓高手之路之java层Binder
    无刷新实时获得数据
    Android画图之抗锯齿
    android 定时器的实现
    将apk文件添加到Android模拟器(AVD)中运行
    Android 屏幕自适应方向尺寸
    经常用得到的安卓数据库基类
    android系统特效详解和修改方法
  • 原文地址:https://www.cnblogs.com/xiaochu/p/4606982.html
Copyright © 2011-2022 走看看