是否可以将函数放在函数以外的其他位置。php文件?一、 是否直接导入模板?
在编写一些代码之前,我需要调用以下内容,为了确保实现这一点,我希望将其置于模板中其他所有内容之上:
function set_region_cookie()
{
if(isset($_POST[\'region\']))
{
// Set Cookie
setcookie(\'region\', $_POST[\'region\'], time()+1209600);
// Reload the current page so that the cookie is sent with the request
header(\'Region: \'.$_SERVER[\'REQUEST_URI\']);
}
}
add_action(\'init\', \'set_region_cookie\');