函数源码function num_replace($string) { if(is_numeric($string)){ return $string; } $a = ['仟','佰','拾']; $b = ['千','百','十']; $string = str_replace($a, $b, $string); $num = 0; $yi = explode('亿', $string); if (count($yi) > 1) { $num += num_replace($yi[0]...
/** * 过滤参数,防SQL注入 * @param string $str 接受的参数 * @return string */ function filter_sql($str) { $farr = array( //"/select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile|dump/is" "/select|insert|u...
<?php $url = 'https://www.xxx.com/index.php'; $path= 'index.html'; /*$contents = file_get_contents($url); //如果出现中文乱码使用下面代码 //$getcontent = iconv(“gb2312″, “utf-8″,file_get_contents($url)); //echo $getcontent; //echo $contents; */ /*curl模拟get提交*/ // 设置请求头, 有时候需要,有时候不用,看请求网址是否有对应的要求 $header[]...
只需在视频链接后面接上?rel=0&autoplay=1<iframe height=500 width=880 src='https://player.youku.com/embed/XNDMzMzI3ODE0OA==?rel=0&autoplay=1' frameborder=0 'allowfullscreen'></iframe>
在做项目的过程中经常需要跨域访问。这里主要介绍一下 PHP 中怎么解决跨域问题。1、允许所有域名访问header('Access-Control-Allow-Origin: *'); 2、允许单个域名访问header('Access-Control-Allow-Origin: https://test.com'); 3、允许多个域名访问在实际项目中最好指定能跨域访问的域名,增加安全性。可以写在一个公共类里面,封装一个方法调用。// 设置能访问的域名 static public $originarr = [ 'https://test1.com', 'https://test2...
<?php $ret = array( 'name' => isset($_POST['name'])? $_POST['name'] : '', 'gender' => isset($_POST['gender'])? $_POST['gender'] : '' ); header('content-type:application:json;charset=utf8'); header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Methods:POST'); he...
package main import ( "fmt" "os" "os/exec" "strconv" "strings" ) func isProcessExist(appName string) (bool, string, int) { appary := make(map[string]int) cmd := exec.Command("cmd", "/C", "ta...
前言:在实际开发中,有时候我们需要等待某个goroutine执行完毕或者几个goroutine执行完毕才退出主程序1.采用时间延时2.采用chan3.采用WaitGroup1.采用时间延时如果我们知道业务函数结束时间,可以使用这种方式。当我们不知道业务函数处理结束时间,这就很尴尬。func main() { go foo() time.Sleep(3 * time.Second) } func foo() { fmt.Println("foo begin.") // 模拟业务耗时,这里在3秒后退出foo方法 for{ ...
c++ 结束程序的几种方式复制代码abort exit一、用abort()结束程序 用abort()表示非正常结束程序。如果要正常结束程序得用exit()二、用exit()结束程序 用exit()它可以使程序正常结束,这个函数需要一个整数作参数返回给操作系统,一般0代表正常结束。三、在main()函数中也可以用return来结束程序 return 1相当于exit(1);
#include <stdio.h>#include <windows.h> #include <io.h> //For access() #define _CRT_SECURE_NO_WARNINGS //消除编译器警告,如fopen不安全 //判断文件或文件目录是否存在 bool checkFileExist(const char *fileName) //不区分大小写 { if (access(fileName,0)) //参数0代...