capture functio...LOGIN

capture function

capture function

Usage:

Anywhere in {capture name="foo" The data between } and {/capture} will be stored in the variable $foo, which is specified by the name attribute.
Passed in the template $smarty.capture.foo accesses this variable.
If the name attribute is not specified, the function will use "default" by default As a parameter.
{capture} must appear in pairs, that is, end with {/capture}. This function cannot be nested.


##eg:

test.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{#pageTitle#}</title>
</head>
<body>
{capture name=banner}
{include file="./test1.html"}
{/capture}
{$smarty.capture.banner}
</body>
</html>

test1.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    1111111111111111
</body>
</html>

Run result:

1111111111111111


Next Section

<?php echo "capture函数";
submitReset Code
ChapterCourseware