【Laravel3.0.0源码阅读分析】section类section.php
发布日期:2021-06-30 20:44:46 浏览次数:2 分类:技术文章

本文共 1698 字,大约阅读时间需要 5 分钟。

* // Start injecting into the "header" section * Section::start('header'); * * // Inject a raw string into the "header" section without buffering * Section::start('header', 'Laravel'); * * * @param string $section * @param string|Closure $content * @return void */ public static function start($section, $content = '') { if ($content === '') ob_start() and static::$last[] = $section; static::append($section, $content); } /** * Inject inline content into a section. * 将内联内容注入一个部分。 * This is helpful for injecting simple strings such as page titles. * 这有助于注入简单的字符串,例如页面标题。 * * // Inject inline content into the "header" section * Section::inject('header', 'Laravel'); * * * @param string $section * @param string $content * @return void */ public static function inject($section, $content) { static::start($section, $content); } /** * Stop injecting content into a section. * 停止将内容注入部分。 * @return void */ public static function stop() { // array_pop-弹出数组最后一个单元 ob_get_clean-得到当前缓冲区的内容并删除当前输出缓。 static::append(array_pop(static::$last), ob_get_clean()); } /** * Append content to a given section. * 将内容附加到给定部分。 * @param string $section * @param string $content * @return void */ protected static function append($section, $content) { if (isset(static::$sections[$section])) { $content = static::$sections[$section].PHP_EOL.$content; } static::$sections[$section] = $content; } /** * Get the string contents of a section. * 获取节的字符串内容。 * @param string $section * @return string */ public static function yield($section) { return (isset(static::$sections[$section])) ? static::$sections[$section] : ''; }}

github地址:      

转载地址:https://liushilong.blog.csdn.net/article/details/117398049 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【Laravel3.0.0源码阅读分析】响应类response.php
下一篇:【Laravel3.0.0源码阅读分析】字符串类str.php

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月07日 05时34分19秒