PHP code example of luxiaok / phpkit
1. Go to this page and download the library: Download luxiaok/phpkit library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
luxiaok / phpkit example snippets
// config/main.php
return [
'components' => [
'kit' => [
'class' => 'phpkit\kit',
],
]
];
$len = 12;
$random_str = Yii::$app->kit->gen_random_str($len);
function actionQrcode(){
$text = Yii::$app->request->get('text','Hello world!');
$type = Yii::$app->request->get('type','text'); // text or url
if ($type=='url') {
$text = urldecode($text);
}
Yii::$app->response->headers->set('Content-type','image/png');
Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
Yii::$app->kit->qrcode($text);
}
$ip = Yii::$app->kit->get_client_ip(); //IPv4,例如:121.51.19.218
$location = Yii::$app->kit->get_ip_location($ip); //中国 广东 深圳 腾讯云
$isPrice = Yii::$app->kit->validatePrice(666); // true
$isPrice = Yii::$app->kit->validatePrice(0.01); // true
$isPrice = Yii::$app->kit->validatePrice(0.012); // false
$isPrice = Yii::$app->kit->validatePrice(-1); // false
$isPrice = Yii::$app->kit->validatePrice(0); // true
use phpkit\tools\http;
$result = http::get($url,$data);
$result = http::post($url,$data);
$result = http::download($url, $save_path, $filename);