php获取ip归属地

  • 黄楚恒
  • 2019-09-03 10:55:12
  • PHP
  • php
<?php
//太平洋网络查询ip,较快
     $ip = "14.117.179.49";
     $get_ip_city = get_ip_city($ip);
     var_dump($get_ip_city);
 
 
     /**
      *$ip  string  必传
      *获取ip归属地 
      *demo 广东省江门市 电信 
      */
     function get_ip_city($ip){     	
	     $ch = curl_init();
	     $url = 'https://whois.pconline.com.cn/ipJson.jsp?ip='.$ip;
	     //用curl发送接收数据
	     curl_setopt($ch, CURLO...
		                        

PHP SFTP简单上传下载实现

  • 黄楚恒
  • 2019-05-13 10:57:11
  • PHP
  • php
1 下载ssh2文件
下载地址 http://windows.php.net/downloads/pecl/releases/ssh2/0.12/
根据自己PHP的版本去下载,其中ts表示线程安全,nts表示不安全。
(可以使用phpinfo()查看需要哪一个,Thread Safety项是enabled表示线程安全)

2 安装ssh2
解压php_ssh2.zip

将 php_ssh.dll、php_ssh2.pdb 放到你的 php 扩展目录下 php/ext/ 下。
将libssh2.dll 复制到 c:/windows/system32 和 c...

基于PHP的微信公众平台开发(TOKEN验证,消息回复)

  • 黄楚恒
  • 2019-01-16 17:53:16
  • PHP
  • php
微信公众平台开发 
实现步骤: 
第一步:填写服务器配置 
登录微信公众平台官网后,在公众平台后台管理页面 - 开发者中心页,点击“修改配置”按钮,填写服务器地址(URL)、Token和EncodingAESKey,其中URL是开发者用来接收微信消息和事件的接口URL。Token可由开发者可以任意填写,用作生成签名(该Token会和接口URL中包含的Token进行比对,从而...
		                        

php实现微信公众平台发红包功能

  • 黄楚恒
  • 2019-01-05 13:58:23
  • PHP
  • php
<?php
/*测试微信企业给个人发红包*/
public function weixin_red_packet(){ 
  // 请求参数 
  // 随机字符串 
  $data['nonce_str']=$this->get_unique_value(); 
  //签名 
  $data['sign']=""; 
  //商户号,输入你的商户号 
  $data['mch_id']="**********"; 
  //商户订单号,可以按要求自己组合28位的商户订单号 
 ...
		                        

php使用redis

  • 黄楚恒
  • 2018-02-03 17:18:46
  • PHP
  • redis
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379); //6379端口号

//使用string类型
$redis->delete("string1");
$redis->set('string1','val1');
$val = $redis->get('string1');
var_dump($val);

$redis->set('string1',5);
$redis->incr('string1',3);
$val = $redis->get('string1');
var_dump($val);

//使用list类型
$redis->delete("list1");
$redis->lpush("list1","a");
$redis->lpush("list1","b");
$redi...
		                        

PHP中如何给日期加上一个月 加一周 加一天

  • 黄楚恒
  • 2017-12-01 09:29:30
  • PHP
  • php
echo   date("Y-m-d",strtotime("+1 month",strtotime("2011-02-04")));

结果为:2011-03-04

echo   date("Y-m-d",strtotime("+1 week",strtotime("2011-02-04")));

结果为:2011-02-11

echo   date("Y-m-d",strtotime("+1 day",strtotime("2011-02-04")));

结果为:2011-02-05

使用函数 date() 实现 
<?php echo $showtime=date("Y-m-d H:i:s");?> 
显示的格式: 年-月-日 时:分:秒

相关时间参数: 
a - "am" 或是 "pm" 
...
		                        

php curl get和post提交

  • 黄楚恒
  • 2017-11-01 09:53:42
  • PHP
  • php
// get方法请求
function getCurl($url) {//get https的内容
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //不输出内容
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

// post方法请求
function postCurl($url, $post) {//get https的内...
		                        

微信js_sdk调用扫一扫接口 php

<?php 
    session_start();
    /**
     * [getWxAcsessToken 获取access_token]
     * @return [type] [description]
     */
    function getWxAcsessToken(){
        $appid = "xxx";//开发者ID(AppID)
        $appsecret = "xxx";//开发者密码(AppSecret)
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret;
        //2.初始化
        $ch = curl_init();
    ...
		                        

PHP冒泡排序和常用数组函数

  • 黄楚恒
  • 2017-08-30 14:21:15
  • PHP
  • php
<?php 
header('content-type:text/html;charset=utf-8');
$array = array('2','1','3','6','4','5');
$arr = array('b','a','c','f','d','e');

/*冒泡排序(一维数组) 基本思想:两两比较待排序数据元素的大小,发现两个数据元素的次序相反时即进行交换,直到没有反序的数据元素为止。 排序过程:设想被排序的数组R[1..N]垂直竖立,将每个数据元素看作有重量的气泡,根...
		                        

PHP导出CSV文件

  • 黄楚恒
  • 2017-08-28 14:21:35
  • PHP
  • CSV
<?php
//注意导出csv文件之前不能输出任何数据,否则失败
header('content-type:text/html;charset=utf-8');
//1.数据库取出数据  
$conn=mysql_connect('localhost','root','root');  
mysql_select_db('blog');
mysql_set_charset('utf8');
$result=mysql_query('select * from blog_user');  
$emps=array();  
while($row=mysql_fetch_assoc($result)){  
    static $i=0;  
    $emps[$i] = $row;  
    $i++;  
}  

//设置内存占...
		                        

Copyright © 2016-2019 709173702@qq.com 版权所有  ICP证粤ICP备16117826号-1
联系邮箱:709173702@qq.com