Skip to content

Instantly share code, notes, and snippets.

@yusureabc
yusureabc / toString.php
Created March 22, 2018 02:26
__toString()方法 是在直接输出对象引用时自动调用的。
<?php
/**
* __toString()方法 是在直接输出对象引用时自动调用的。
* 魔术方法: http://www.php.net/manual/zh/language.oop5.magic.php
*/
class TestClass{
public $foo;
public function __construct($foo) {
$this->foo = $foo;
}
@yusureabc
yusureabc / getIp.php
Created March 21, 2018 06:47
获取客户端 IP( 适用于 Docker 环境 )
<?php
/**
* 获取客户端 IP
* @author Sure Yu http://yusure.cn
* @date 2018-03-21
* @param [param]
* @return [type] [description]
*/
function getIP()
{
@yusureabc
yusureabc / closure_bind.php
Created March 19, 2018 15:50
闭包 bind 和 bindTo 的学习
<?php
/* 参考资料:https://www.cnblogs.com/eleven24/p/7487923.html */
$closure = function ($name, $age) {
$this->name = $name;
$this->age = $age;
};
class Person {
public $name;
public $age;
@yusureabc
yusureabc / SolarizedDarkModify.xcs
Created February 23, 2018 09:10
Xshell 配色方案
[SolarizedDarkModify]
text=839496
cyan(bold)=00ffff
text(bold)=e9e9e9
magenta=c000c0
green=80ff00
green(bold)=3c5a38
background=042028
cyan=00c0c0
red(bold)=ff0000
@yusureabc
yusureabc / dump.php
Created February 23, 2018 08:33
php将调试信息写如到文件
<?php
/**
* 调试信息写文件
* 在 shell 窗口用 tail -f yusure_dubug.txt 配合查看日志
*/
function sure_dump( $data )
{
file_put_contents( 'yusure_dubug.txt' , var_export( $data, true ) . PHP_EOL, FILE_APPEND );
}
@yusureabc
yusureabc / laravel_nginx.conf
Created January 23, 2018 10:02
laravel nginx 伪静态配置
location / {
try_files $uri $uri/ /index.php?$query_string;
}
@yusureabc
yusureabc / ntunnel_mysql.php
Created January 18, 2018 07:40
Navicat mysql 内网转发脚本
<?php //version my202
//set allowTestMenu to false to disable System/Server test page
$allowTestMenu = true;
$use_mysqli = function_exists("mysqli_connect");
header("Content-Type: text/plain; charset=x-user-defined");
error_reporting(0);
set_time_limit(0);
@yusureabc
yusureabc / log_format
Last active March 1, 2018 09:27
Nginx 反向代理配置
/* CDN、反向代理 获取真实 ip 的配置方法 */
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main
@yusureabc
yusureabc / Sublime3-Settings-User
Created January 11, 2018 06:34
Sublime3编辑器配置
{
"caret_style": "phase",
"color_scheme": "Packages/User/SublimeLinter/Laravel (SL).tmTheme",
"dpi_scale": 1.0,
"font_face": "Consolas",
"font_options":
[
],
"font_size": 14,
"highlight_modified_tabs": true,
@yusureabc
yusureabc / build_index.php
Created January 5, 2018 07:22
首页静态化脚本
<?php
/**
* 首页静态化脚本
* Author: Yusure
* Blog: yusure.cn
*/
ini_set( 'date.timezone', 'PRC' );
/* 缓存过期时间 单位:秒 */
$expire = 86400;