<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>gt on 施国鹏 (seth-shi)</title><link>https://sethix.com/zh-cn/tags/gt/</link><description>Recent content in gt on 施国鹏 (seth-shi)</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Tue, 10 Jul 2018 12:46:43 +0800</lastBuildDate><atom:link href="https://sethix.com/zh-cn/tags/gt/index.xml" rel="self" type="application/rss+xml"/><item><title>Laravel 中简约而不简单的 Macroable 宏指令</title><link>https://sethix.com/zh-cn/posts/2018071012/</link><pubDate>Tue, 10 Jul 2018 12:46:43 +0800</pubDate><guid>https://sethix.com/zh-cn/posts/2018071012/</guid><description>百度百科的定义：
计算机科学里的宏（Macro)，是一种批量处理的称谓。一般说来，宏是一种规则或模式，或称语法替换 ，用于说明某一特定输入（通常是字符串）如何根据预定义的规则转换成对应的输出（通常也是字符串)。这种替换在预编译时进行，称作宏展开。
我一开始接触宏是在大学上计算机基础课程时，老师讲office时说的。那时老师介绍宏操作时没太在意，只记得这一操作很强大，它能使日常工作变得更容易。 今天我们讲讲Laravel中的宏操作 首先完整的源码 &amp;lt;?php namespace Illuminate\Support\Traits; use Closure; use ReflectionClass; use ReflectionMethod; use BadMethodCallException; trait Macroable { /** * The registered string macros. * * @var array */ protected static $macros = []; /** * Register a custom macro. * * @param string $name * @param object|callable $macro * * @return void */ public static function macro($name, $macro) { static::$macros[$name] = $macro; } /** * Mix another object into the class.</description></item></channel></rss>