汇成软件 Create the world!!!

php调用chatgpd接口输出

<?php
$url = 'https://api.openai.com/v1/completions';
$data = array("model"=> "text-davinci-003",
          "prompt"=> "帮我用C#开发一个生成二维码的程序",
          "temperature"=> 0.7,
          "max_tokens"=> 256,
          "top_p"=> 1,
          "frequency_penalty"=> 0,
          "presence_penalty"=> 0);
$data_string = json_encode($data);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Authorization: Bearer apikey',
    'Content-Length: ' . strlen($data_string))
);

$result = json_decode(curl_exec($ch),true);

curl_close($ch);

print_r($result);
 
echo  $result["choices"][0]["text"];


 ?>
作者:admin 分类:php 浏览:265 评论:0

php字符截取

substr(变量, 0,506)

作者:admin 分类:php 浏览:370 评论:0

短地址生成,全套配置教程

nginx 配置

location / {

rewrite  ^(.*)$  /index.php?s=/$1  last;

}



code 

作者:admin 分类:php 浏览:638 评论:0

php.ini 7.3设置

date.timezone = PRC
display_errors = On

网络保存图片,以及微信获取手机号码:
windows下的PHP,只需要到php.ini中把前面的 ; 删掉,重启服务就可以了。
extension=php_openssl.dllphp7.3
extension=openssl

作者:admin 分类:php 浏览:715 评论:0

php过滤emod与特殊字符

<?php 
function xml_entities($string) {
//过滤emod
$ts_zifu= json_encode($string);
$str = json_decode(preg_replace("#(\\\ud[0-9a-f]{3})#i", "", $ts_zifu));
//过滤特殊字符
$text=preg_replace("/[[:punct:]\s]/",' ',$str);
$text=urlencode($text);
$text=preg_replace("/(%7E|%60|%21|%40|%23|%24|%25|%5E|%26|%27|%2A|%28|%29|%2B|%7C|%5C|%3D|\-|_|%5B|%5D|%7D|%7B|%3B|%22|%3A|%3F|%3E|%3C|%2C|\.|%2F|%A3%BF|%A1%B7|%A1%B6|%A1%A2|%A1%A3|%A3%AC|%7D|%A1%B0|%A3%BA|%A3%BB|%A1%AE|%A1%AF|%A1%B1|%A3%FC|%A3%BD|%A1%AA|%A3%A9|%A3%A8|%A1%AD|%A3%A4|%A1%A4|%A3%A1|%E3%80%82|%EF%BC%81|%EF%BC%8C|%EF%BC%9B|%EF%BC%9F|%EF%BC%9A|%E3%80%81|%E2%80%A6%E2%80%A6|%E2%80%9D|%E2%80%9C|%E2%80%98|%E2%80%99|%EF%BD%9E|%EF%BC%8E|%EF%BC%88)+/",' ',$text);
$str=urldecode($text);
//过滤指定的空格与字符
  return   strtr(
        $str, 
        array(
            "<" => "",
            ">" => "",
            '"' => "",
            "'" => "",
            "&" => "",
            "|" => "",
            "-" => "",
            "–" => "",
            ":" => "",
            "Ⅱ" => "2",
            "”" => "",
            "】" => "",
            "【" => "",
            "%" => "",
            "(" => "",
            ")" => "",
            ";" => "",  
            "  " => "",      
        )
    );

}

$string="I love you>>><<,?❤?????‍??????✔?‍??‍???‍?;asdfasdfasdf;";
echo xml_entities($string) ;
 ?>
作者:admin 分类:php 浏览:1418 评论:0

批量插入

一条insert语句批量插入多条记录

原创|浏览:138554|更新:2017-12-19 08:21

一条insert语句批量插入多条记录


常见的insert语句,向数据库中,一条语句只能插入一条数据:


insert into persons 


(id_p, lastname , firstName, city )


作者:admin 分类:php 浏览:608 评论:0

php替换函数--数组写法

<?php 

$my_name='&&&&';

//echo  substr(xml_entities($my_name),0,135);
ECHO xml_entities($my_name);


function xml_entities($string) {
    return strtr(
        $string, 
        array(
            "<" => "",
            ">" => "",
            '"' => "",
            "'" => "",
            "&" => "",
            "|" => "",
            "-" => "",
            "–" => "",
            ":" => "",
            "Ⅱ" => "2",
            
        )
    );
}
 ?>
作者:admin 分类:php 浏览:596 评论:0