1. Go to this page and download the library: Download yll1024335892/phptools 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/ */
yll1024335892 / phptools example snippets
use Yll1024335892\Phptools\UploadClass;
class indexController{
public function index(){
//提交比对
if(!empty($_FILES['filename'])){
$uper = new UploadClass('filename', 'upload', '2.png');
$uploadedFile = $uper->upload();
if($uploadedFile){
echo '上传文件路径 : '.$uploadedFile;
}else{
echo $uper->error;
}
}
}
}
//html表单
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="filename" value="" />
<input type="submit" id="" value="提交" />
</form>
use namespace Yll1024335892\Phptools\ServerClass;
class indexController{
public function index(){
$serverInfo = ServerClass::info();
p($serverInfo);
}
}
use Yll1024335892\Phptools\CurlClass;
class indexController{
public function index(){
$curl = new CurlClass();
$res = $curl->get('http://api.hcoder.net');
//返回结果
echo $res;
}
}
use Yll1024335892\Phptools\CurlClass;
class indexController{
public function index(){
$curl = new CurlClass();
//post 数据
$data = array('name' => 'grace', 'age' => 10);
$res = $curl->post('http://api.hcoder.net', $data);
//curl 状态
p($curl->http_status);
//传输时间毫秒
echo $curl->speed;
//返回结果
echo $res;
}
}
use Yll1024335892\Phptools\DownloadClass;
class indexController{
public function index(){
//不设置下载文件名
DownloadClass::download('index.php');
//设置下载文件名
DownloadClass::download('index.php', '2.php');
}
}
use Yll1024335892\Phptools\IpClass;
class indexController{
public function index(){
echo IpClass::getIp();
}
}
$timer = new TimerClass();
echo $timer->currentYear();
$timer = new TimerClass();
echo $timer->currentMonth();
$timer = new TimerClass();
echo $timer->currentDay();
$timer = new TimerClass();
echo $timer->currentHour();
$timer = new TimerClass();
echo $timer->currentMin();
$timer = new TimerClass();
echo $timer->currentSecond();
参数:时间戳
演示:
$timer = new TimerClass();
echo $timer->fromTime($timer->timeStamp('2018-04-24 15:48:04'));
参数: xml 内容
演示:
$xmlObj = new XmlClass();
$xmlContent = file_get_contents('demo.xml');
$xml = $xmlObj->reader($xmlContent);
print_r($xml);
使用 phpGrace\tools\reflex 类的静态方法 r,参数:类或对象。
use Yll1024335892\Phptools\ReflexClass;
use Yll1024335892\Phptools\MailerClass;
class indexController{
public function index(){
$mailer = new MailerClass();
ReflexClass::r($mailer);
}
}