Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

register_function()

register_function() -- secara dinamis meregistrasi plugin fungsi template

Deskripsi

void register_function ( string name, mixed impl [, bool cacheable [, mixed cache_attrs]])

Mengirimkan nama fungsi template, diikuti oleh nama fungsi PHP yang mengimplementasikannya.

Fungsi-php callback function dapat berupa:

  • String yang berisi nama fungsi

  • Sebuah array dalam bentuk array(&$object, $method) dengan &$object menjadi referensi ke sebuah obyek dan $method menjadi string yang berisi nama-metode

  • Sebuah array dalam bentuk array($class, $method) dengan $class menjadi nama kelas dan $method menjadi metode kelas.

cacheable dan cache_attrs dapat diabaikan. Lihat mengontrol output plugin yang dapat di-cache atas bagaimana menggunakannya dengan benar.

Teladan 13-1. register_function()

register_function(\'date_now\', \'print_current_date\'); function print_current_date($params, &$smarty) { if(empty($params[\'format\'])) { $format = "%b %e, %Y"; } else { $format = $params[\'format\']; } return strftime($format,time()); } ?>'); ?>

Dan dalam template

{date_now}

{* atau untuk membentuk secara berbeda *}
{date_now format="%Y/%m/%d"}

Lihat juga unregister_function() dan seksi fungsi plugin.

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 14 plus 11? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk