让你的Smarty更聪明_PHP
SMARTY
一、扩展你的Smarty1、准备功夫
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<font size=
"2"
><font face=
"Verdana"
>PHP代码:</font><hr></font><code><font color=
"#000000"
>
<font color=
"#0000bb"
><br></font><font color=
"#007700"
>
function
</font><font color=
"#0000bb"
>Smarty_function_page </font><font color=
"#007700"
>( </font><font color=
"#0000bb"
>
$params
</font><font color=
"#007700"
>, &</font><font color=
"#0000bb"
>
$Smarty
</font><font color=
"#007700"
>)
<br>{
<br> </font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>= </font><font color=
"#dd0000"
>
'#'
</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$space
</font><font color=
"#007700"
>= </font><font color=
"#dd0000"
>
' '
</font><font color=
"#007700"
>;
<br>
<br> </font><font color=
"#0000bb"
>
$frist
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>NULL</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$last
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>NULL</font><font color=
"#007700"
>;
<br>
<br> </font><font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>5</font><font color=
"#007700"
>;
<br>
<br> </font><font color=
"#0000bb"
>extract</font><font color=
"#007700"
>(</font><font color=
"#0000bb"
>
$params
</font><font color=
"#007700"
>);
<br>
<br>
if
( !</font><font color=
"#0000bb"
>
$row
</font><font color=
"#007700"
>|| </font><font color=
"#0000bb"
>
$row
</font><font color=
"#007700"
><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>)
return
</font><font color=
"#dd0000"
>
' '
</font><font color=
"#007700"
>;
<br>
<br> </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$row
</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$now
</font><font color=
"#007700"
>? </font><font color=
"#0000bb"
>
$now
</font><font color=
"#007700"
>: </font><font color=
"#0000bb"
>1</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$offset
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>2</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$offset
</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>+ </font><font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$offset
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>1</font><font color=
"#007700"
>;
<br>
<br>
if
( </font><font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>> </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>)
<br> {
<br> </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>1</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>;
<br> }
<br>
else
<br> {
<br>
if
( </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
><font color=
"#0000bb"
>1</font><font color=
"#007700"
>)
<br> {
<br> </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>+ </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>1</font><font color=
"#007700"
>;
<br>
if
( ( </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>) <font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>&& ( </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>) <font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>)
<br> {
<br> </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>;
<br> }
<br> }
<br>
elseif
( </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>> </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>)
<br> {
<br> </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>+ </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>;
<br> </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>;
<br>
if
( ( </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>) <font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>&& ( </font><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>) <font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>)
<br> {
<br> </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>
$page
</font><font color=
"#007700"
>+ </font><font color=
"#0000bb"
>1</font><font color=
"#007700"
>;
<br> }
<br> }
<br> }
<br>
<br>
if
( </font><font color=
"#0000bb"
>
$frist
</font><font color=
"#007700"
>&& ( </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>) >= </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>) </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>[</font><font color=
"#dd0000"
>
'frist'
</font><font color=
"#007700"
>] = </font><font color=
"#dd0000"
>
'<a href="'
%20</font><font%20color=">. </a></font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>. </font><font color=
"#dd0000"
>
'1">'
</font><font color="#007700
">. </font><font color="
#0000bb
">$frist </font><font color="
#007700
">. </font><font color="
#dd0000
">''</font><font color="
#007700">;
<br>
if
( </font><font color=
"#0000bb"
>
$prev
</font><font color=
"#007700"
>&& ( </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>- </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>) >= </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>) </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>[</font><font color=
"#dd0000"
>
'prev'
</font><font color=
"#007700"
>] = </font><font color=
"#dd0000"
>
'<a href="'
%20</font><font%20color=">. </a></font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>. </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>. </font><font color=
"#dd0000"
>
'">'
</font><font color="#007700
">. </font><font color="
#0000bb
">$prev </font><font color="
#007700
">. </font><font color="
#dd0000
">''</font><font color="
#007700">;
<br>
for
( </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$from
</font><font color=
"#007700"
>; </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
><font color=
"#0000bb"
>
$to
</font><font color=
"#007700"
>; </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>++ )
<br> {
<br>
if
( </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>== </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>)
<br> {
<br> </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>[</font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>] = </font><font color=
"#dd0000"
>
'<a href="'
%20</font><font%20color=">. </a></font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>. </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>. </font><font color=
"#dd0000"
>
'" class="nowpage" target="_self">['
</font><font color="#007700
">. </font><font color="
#0000bb
">$i </font><font color="
#007700
">. </font><font color="
#dd0000
">']'</font><font color="
#007700">;
<br> }
<br>
else
<br> {
<br> </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>[</font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>] = </font><font color=
"#dd0000"
>
'<a href="'
%20</font><font%20color=">. </a></font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>. </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>. </font><font color=
"#dd0000"
>
'" target="_self">'
</font><font color="#007700
">. </font><font color="
#0000bb
">$i </font><font color="
#007700
">. </font><font color="
#dd0000
">''</font><font color="
#007700">;
<br> }
<br> }
<br>
if
( </font><font color=
"#0000bb"
>
$next
</font><font color=
"#007700"
>&& ( </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>+ </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>) <font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>) </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>[</font><font color=
"#dd0000"
>
'next'
</font><font color=
"#007700"
>] = </font><font color=
"#dd0000"
>
'<a href="'
%20</font><font%20color=">. </a></font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>. </font><font color=
"#0000bb"
>
$i
</font><font color=
"#007700"
>. </font><font color=
"#dd0000"
>
'" target="_self">'
</font><font color="#007700
">. </font><font color="
#0000bb
">$next </font><font color="
#007700
">. </font><font color="
#dd0000
">''</font><font color="
#007700">;
<br>
if
( </font><font color=
"#0000bb"
>
$last
</font><font color=
"#007700"
>&& ( </font><font color=
"#0000bb"
>
$curr_page
</font><font color=
"#007700"
>+ </font><font color=
"#0000bb"
>1 </font><font color=
"#007700"
>) <font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>) </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>[</font><font color=
"#dd0000"
>
'last'
</font><font color=
"#007700"
>] = </font><font color=
"#dd0000"
>
'<a href="'
%20</font><font%20color=">. </a></font><font color=
"#0000bb"
>
$href
</font><font color=
"#007700"
>. </font><font color=
"#0000bb"
>
$pages
</font><font color=
"#007700"
>. </font><font color=
"#dd0000"
>
'" target="_self">'
</font><font color="#007700
">. </font><font color="
#0000bb
">$last </font><font color="
#007700
">. </font><font color="
#dd0000
">''</font><font color="
#007700">;
<br>
<br>
return
</font><font color=
"#0000bb"
>implode</font><font color=
"#007700"
>( </font><font color=
"#0000bb"
>
$space
</font><font color=
"#007700"
>, </font><font color=
"#0000bb"
>
$p
</font><font color=
"#007700"
>);
<br>} </font><font color=
"#ff8000"
>
// end func<br></font><font color="#0000bb"></font>
</font>
</font></font></font></font></font></font></font></font></font></code><hr>
ログイン後にコピー
将上面的代码命名为"function.page.php"保存到Smarty的plugins目录里
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<font size=
"2"
><font face=
"verdana,arial,helvetica"
>代码:</font><hr></font>
<title> New Document </title>
<meta name=
"Generator"
content=
"EditPlus"
>
<meta name=
"Author"
content=
""
>
<meta name=
"Keywords"
content=
""
>
<meta name=
"Description"
content=
""
>
{page row=10}
{page row=10 now=5}
{page row=10 now=5 href=
"plugins.php?a=1&b=2&page="
frist=
"第一页"
prev=
"上一页"
next=
"下一页"
last=
"最后页"
}
{page row=10 now=5 href=
"plugins.php?a=1&b=2&page="
frist=
"第一页"
prev=
"上一页"
next=
"下一页"
last=
"最后页"
}
{page row=10 now=1 href=
"plugins.php?a=1&b=2&page="
frist=
"第一页"
prev=
"上一页"
next=
"下一页"
last=
"最后页"
}
{page row=10 now=10 href=
"plugins.php?a=1&b=2&page="
frist=
"第一页"
prev=
"上一页"
next=
"下一页"
last=
"最后页"
}
<hr>
ログイン後にコピー
将上面的代码命名为"plugins.html"保存到Smarty的template目录里
2、测试程序
1
2
3
4
<font size=
"2"
><font face=
"verdana,arial,helvetica"
>PHP代码:</font><hr></font><code><font color=
"#000000"
>
<font color=
"#0000bb"
><br>
$Smarty
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>display</font><font color=
"#007700"
>( </font><font color=
"#dd0000"
>
'plugins.html'
</font><font color=
"#007700"
>);<br></font><font color=
"#0000bb"
></font>
</font>
</code><hr>
ログイン後にコピー
3、使用说明
我懒得打了,对比一下"plugins.html"的5个{page}用法,以及看看显示出来的效果就明白是什么了
4、插件说明
“《Smarty手册》第十六章.以插件扩展Smarty ”的应用。像中文字符截取之类的都可以以plugins扩展Smarty,Smarty自带的截取不支持中文。
二、Smarty自动生成静态页面
如果你的文件扩展名为".html"~~~~~嘿嘿,这不就是静态页面了吗?-_-!
至于怎么取得静态的文件名呢?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<font size=
"2"
><font face=
"verdana,arial,helvetica"
>PHP代码:</font><hr></font><code><font color=
"#000000"
>
<font color=
"#0000bb"
><br></font><font color=
"#ff8000"
>
/**
<br> *
<br> */
<br></font><font color=
"#007700"
>
class
</font><font color=
"#0000bb"
>template </font><font color=
"#007700"
>
extends
</font><font color=
"#0000bb"
>Smarty
<br></font><font color=
"#007700"
>{
<br>
<br> </font><font color=
"#ff8000"
>
/**
<br> *
<br> */
<br> </font><font color=
"#007700"
>
function
</font><font color=
"#0000bb"
>template </font><font color=
"#007700"
>()
<br> {
<br> </font><font color=
"#0000bb"
>
$this
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>Smarty</font><font color=
"#007700"
>();
<br> } </font><font color=
"#ff8000"
>
// end func
<br>
<br>
/**
<br> *
<br> */
<br> </font><font color=
"#007700"
>
function
</font><font color=
"#0000bb"
>name </font><font color=
"#007700"
>( </font><font color=
"#0000bb"
>
$tpl_file
</font><font color=
"#007700"
>, </font><font color=
"#0000bb"
>
$cache_id
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>null</font><font color=
"#007700"
>, </font><font color=
"#0000bb"
>
$compile_id
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>null </font><font color=
"#007700"
>)
<br> {
<br>
<br>
if
(!isset(</font><font color=
"#0000bb"
>
$compile_id
</font><font color=
"#007700"
>)) </font><font color=
"#0000bb"
>
$compile_id
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$this
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>compile_id</font><font color=
"#007700"
>;
<br>
<br> </font><font color=
"#0000bb"
>
$_auto_id
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$this
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>_get_auto_id</font><font color=
"#007700"
>( </font><font color=
"#0000bb"
>
$cache_id
</font><font color=
"#007700"
>, </font><font color=
"#0000bb"
>
$compile_id
</font><font color=
"#007700"
>);
<br> </font><font color=
"#0000bb"
>
$_cache_file
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$this
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>_get_auto_filename</font><font color=
"#007700"
>( </font><font color=
"#0000bb"
>
$this
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>cache_dir</font><font color=
"#007700"
>, </font><font color=
"#0000bb"
>
$tpl_file
</font><font color=
"#007700"
>, </font><font color=
"#0000bb"
>
$_auto_id
</font><font color=
"#007700"
>);
<br>
<br>
return
</font><font color=
"#0000bb"
>
basename
</font><font color=
"#007700"
>( </font><font color=
"#0000bb"
>
$_cache_file
</font><font color=
"#007700"
>);
<br> } </font><font color=
"#ff8000"
>
// end func
<br></font><font color=
"#007700"
>} </font><font color=
"#ff8000"
>
// end class
<br>
<br></font><font color=
"#0000bb"
>
$Smarty
</font><font color=
"#007700"
>=
new
</font><font color=
"#0000bb"
>template</font><font color=
"#007700"
>;
<br></font><font color=
"#0000bb"
>
$file_name
</font><font color=
"#007700"
>= </font><font color=
"#0000bb"
>
$Smarty
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>name</font><font color=
"#007700"
>( </font><font color=
"#dd0000"
>
'plugins.html'
</font><font color=
"#007700"
>, </font><font color=
"#dd0000"
>
'cache_name'
</font><font color=
"#007700"
>);</font><font color=
"#ff8000"
>#html文件的名字(不包含路径)
<br>
<br></font><font color=
"#0000bb"
>
$Smarty
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>cache_lifetime </font><font color=
"#007700"
>= -</font><font color=
"#0000bb"
>1</font><font color=
"#007700"
>;</font><font color=
"#ff8000"
>#静态文件永不过期
<br></font><font color=
"#0000bb"
>
$Smarty
</font><font color=
"#007700"
>-></font><font color=
"#0000bb"
>fetch</font><font color=
"#007700"
>( </font><font color=
"#dd0000"
>
'plugins.html'
</font><font color=
"#007700"
>, </font><font color=
"#dd0000"
>
'cache_name'
</font><font color=
"#007700"
>);</font><font color=
"#ff8000"
>#生成静态html文件<br></font><font color=
"#0000bb"
></font>
</font>
</code><hr>
ログイン後にコピー
Smarty的功能很多很多(使用了半年,深有体会),还有待大家继续发掘。。。。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









src と href はそれぞれ、1. src は、source の略語で、外部リソースのパスを指定するために使用されます。通常、画像、オーディオ、ビデオなどの外部ファイルを埋め込むために使用されます。src 属性は通常、 img、script、iframe などのタグで使用されます。 ; 2. href は、ハイパーテキスト参照の略で、ハイパーリンクのターゲット リソースのパスを指定するために使用されます。通常、外部ドキュメントまたは他のページへのリンクに使用されます。 href 属性は通常、a や link などのタグで使用されます。

Vue プロジェクトでデータ ページングと表示の最適化を実装します。Vue プロジェクトでは、ページに大量のデータを表示する必要がある場合、通常、ユーザー エクスペリエンスを向上させるためにデータ ページングと表示の最適化を実行する必要があります。この記事では、Vue を使用して次のことを行う方法を紹介します。データ ページングと表示の最適化を実装し、具体的なコード例を提供します。 1. データページング データページングとは、大量のデータを一定の規則に従って複数のページに分割してページ上に表示することをいいます。次の手順を使用して、Vue プロジェクトにデータ ページングを実装できます: データ ソースを定義します。

src 属性と href 属性は HTML で一般的に使用される属性であり、外部リソースを読み込むために使用されます。目的は似ていますが、使用方法や目的にはいくつかの違いがあります。 src 属性: src 属性は、文書に埋め込む外部リソースを指定するために使用され、主に外部スクリプト ファイルやメディア ファイルを HTML 文書に導入するために使用されます。これは次の状況で使用できます。 外部 JavaScript ファイルを導入する: src 属性を通じて外部 JavaScript ファイルを HTML ページにリンクします。

href および src によって送信されたリクエストを取得します。詳細説明: 1. href 属性は、リンク先のリソースを指定するために使用されます。外部スタイルシートを参照する場合は、CSS ファイルを取得するために GET リクエストを送信します。ドキュメントを参照する場合は、CSS ファイルを取得するために GET リクエストを送信します。指定されたHTMLファイルを取得します 画像を参照する場合はGETリクエストを送信します 指定された画像ファイルを取得するには; 2. src属性は埋め込みリソースのURLを指定します 画像を参照する場合はGETリクエストを送信します指定された画像ファイルを取得するためのGETリクエスト、音声を参照する場合には、指定された音声ファイルなどを取得するためのGETリクエストを送信します。

現在、Web サイト開発は重要なコンポーネント テンプレート エンジンから切り離せません。テンプレート エンジンとは、ページ テンプレートとデータを組み合わせて特定の形式の HTML コードを生成するツールを指します。テンプレート エンジンはコードの重複を大幅に削減し、ページのダイナミクスを向上させることができるため、さまざまな Web サイト開発フレームワークにおいて、テンプレート エンジンは不可欠なコンポーネントです。最も一般的で人気のあるテンプレート エンジンの 1 つは Smarty です。 Smarty は DSL (DomainSpecif

現代の Web 開発では、フロントエンドとバックエンドの分離が非常に一般的な傾向になっており、これにより開発者はプロジェクトをより適切に組織し、プロジェクト開発の効率を向上させることができます。 PHP と Smarty は非常によく使用される 2 つのテクノロジであり、フロントエンドとバックエンドの分離開発を実現するために使用できます。この記事では、PHPとSmartyを使ってフロントエンドとバックエンドの分離開発を実現する方法を紹介します。フロントエンドとバックエンドの分離開発とは何ですか? 従来の Web 開発では、フロントエンドは主にページのプレゼンテーションとバックエンドとの対話ロジックを担当します。バックエンドは主にビジネスを担当します

src と href の違いは何ですか?早く調べてください! Web 開発のプロセスでは、src と href の 2 つの属性がよく使用されます。似ているように見えますが、実際には用途や適用可能なシナリオが異なります。この記事では、src と href の違いを詳しく掘り下げ、具体的なコード例を示して説明します。 HTML では、src は埋め込みまたは参照する外部リソースを指定するために使用される属性で、通常は画像、音声、ビデオ、またはスクリプト ファイルを参照するために使用されます。これとは異なり、href はハイパーリンクです

PHP 開発者として、テンプレート エンジンを使用するのは自然な選択です。 Smarty は、HTML/CSS/JavaScript を PHP コードから分離する方法を提供する人気のテンプレート エンジンで、開発者がプロジェクトをより適切に整理および管理できるようにします。この記事では、PHP 開発中に Smarty テンプレート エンジンを使用する方法を学びます。 1. Smarty をインストールする 前に、Smarty をインストールする必要があります。この記事では、Composer を使用してインストールします
