<?php
declare(strict_types=1);
require __DIR__.'/vendor/autoload.php';
<?php | |
// json_decode returns NULL with validated json data, error: "Control character error, possibly incorrectly encoded" | |
json_decode(preg_replace('/[[:cntrl:]]/mu', '', $json), true); |
<?php | |
// prepare headers for API call | |
$request_headers = array(); | |
// prepare the url of the api I am calling | |
$api_url = "http://api.example.com?parameters=whatever"; | |
// append streamdata sandbox proxy | |
$url = 'https://streamdata.motwin.net/' . $api_url; |
<?php
// 子查询
ServerNotice::query()
->select('*')
->whereRaw('(SELECT COUNT(*) FROM xb_server_notice AS sn WHERE xb_server_notice.zone_id = sn.zone_id AND xb_server_notice.updated_at < sn.updated_at) < 2')
->orderBy('zone_id')
->orderByDesc('updated_at')
->get()
<?php | |
/** | |
* curl 并发请求示例 | |
*/ | |
$startTime = microtime(true); | |
$curls = []; | |
for ($i = 1; $i <= 10; $i++) { | |
// 创建 curl 句柄 | |
$curls[$i] = $curl = curl_init(); |
本文由 简悦 SimpRead 转码, 原文地址 github.com
Caution!
This is the documentation for Pimple 3.x. If you are using Pimple 1.x, read the Pimple 1.x documentation. Reading the Pimple 1.x code is also a good way to learn more about how to create a simple Dependency Injection Container (recent versions of Pimple are more focused on performance).
Pimple 是一个简单的 PHP 依赖注入容器 (Dependency Injection Container)。
<?php | |
/** | |
* 薄雾算法 | |
* | |
* 1 2 48 56 64 | |
* +------+-----------------------------------------------------+----------+----------+ | |
* retain | increas | salt | sequence | | |
* +------+-----------------------------------------------------+----------+----------+ | |
* 0 | 0000000000 0000000000 0000000000 0000000000 0000000 | 00000000 | 00000000 | |
Translations: Korean (by Yongwoo Lee)
Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.
I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).