Ask Smarty registration function problem.
$smarty->register_function (' Dateline ', ' handle_dateline '); This is the registration function, what does the first parameter mean?
function Handle_dateline ($params, & $smarty) {}//This is the registered functions, what do these 2 parameters mean?
Does registering a function cause a function to execute? Is it similar to calling a function?
Reply to discussion (solution)
$smarty->register_function (' Dateline ', ' handle_dateline ');
Dateline is the name used in the template.
Such as
{Dateline time= "$time" format= "y-m-d"}
Instead of
{handle_dateline time= "$time" format= "y-m-d"}
Oh, to find their own sins by
function Handle_dateline ($params, & $smarty) {}
$params An array of arguments passed in, such as two elements in the previous example
function body you might write this.
Extract ($params);
echo Date ($format, $time);
$smarty the Smarty object itself, because you might need to access $smarty properties and methods within the function body
$smarty->register_function (' Dateline ', ' handle_dateline ');
Dateline is the name used in the template.
Such as
{Dateline time= "$time" format= "y-m-d"}
Hello, so to speak,
$smarty->register_function (' Dateline ', ' handle_dateline ');
does not pass any parameters to function Handle_dateline ($params, & $smarty) {}??
The statement above the registration function will not cause the function handle_dateline ($params, & $smarty) {} "to execute?"
Does not execute, it just registers a function that needs to be executed when you call it in the template, and the parameters are passed at this time.
Does not execute, it just registers a function that needs to be executed when you call it in the template, and the parameters are passed at this time.
Parameters are passed at the time of invocation, that is, unrelated to the registration function. What's the use of the registration function?? Is it just to make its value appear in the TPL?
The purpose of registration is to let Smarty find him, otherwise it will be wrong!
Plainly, it is registering a function that allows you to invoke it in the TPL.