Quick question about a global function

Hi there,

I just have a quick question regarding a global function. I would like to use a function in many controllers what should I do?

Create a model (e.g. functions) write methods inside, and after call :

$functions = new functions;

$functions->myMethod?

Any suggestion are welcome :)

Hi

Check out the Cookbook article on using shortcut functions - http://www.yiiframew…oc/cookbook/31/

I think when you say 'should I create a model' you mean 'class'.  Rather than that, I would just follow the suggestion in the Cookbook article and create an included PHP file.  I might then preface all my global functions with a letter to avoid any clashes (eg. PRemoveSlashes(), PAddSpaces())

Hope that helps somewhat.

A

As for me, I created my own classes (like String, Img and so on) and put them in "vendors" folder.

Then I just added 'application.vendors.*' to import array.

Ok thank you for your feedbacks :)

Think I will create a class under a folder and add it in the config file to be included :)

Cheers