Difference between #7 and #8 of
Understanding Autoloading, Helper Classes and Helper Functions

Revision #8 has been created by Steve Friedl on Aug 10, 2011, 3:42:50 PM with the memo:

Renamed helpers.inc to helpers.php
« previous (#7) next (#9) »

Changes

Title unchanged

Understanding Autoloading, Helper Classes and Helper Functions

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Helper functions; autoloading

Content changed

[...]
```
but this is tedious: it's much more convenient to use regular ordinary functions to do this, and it's easy to achieve in Yii (though it does not involve the autoloader).

### 1. Create helpers function file

I usually define helpers in `protected/components/helpers.
incphp`: ```php <?php // protected/components/helpers.incphp

function startsWith($needle, $haystack)
[...]
// protected/config/main.php

require_once( dirname(__FILE__) . '/../components/helpers.
incphp');

...
```
This done, any part of the application can use the helper functions defined here:
[...]
22 0
26 followers
Viewed: 122 412 times
Version: 1.1
Category: Tutorials
Written by: Steve Friedl
Last updated by: GOsha
Created on: Mar 26, 2011
Last updated: 12 years ago
Update Article

Revisions

View all history