// Built-in types
$variable = null; // null type
// Scalar types
$boolVar = true; // bool type
$intVar = 42; // int type
$floatVar = 3.14; // float type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. | |
# Initialization code that may require console input (password prompts, [y/n] | |
# confirmations, etc.) must go above this block; everything else may go below. | |
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
fi | |
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// json_decode returns NULL with validated json data, error: "Control character error, possibly incorrectly encoded" | |
json_decode(preg_replace('/[[:cntrl:]]/mu', '', $json), true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 薄雾算法 | |
* | |
* 1 2 48 56 64 | |
* +------+-----------------------------------------------------+----------+----------+ | |
* retain | increas | salt | sequence | | |
* +------+-----------------------------------------------------+----------+----------+ | |
* 0 | 0000000000 0000000000 0000000000 0000000000 0000000 | 00000000 | 00000000 | |
NewerOlder