📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials CodeIgniter 4 Helpers in CI4

Helpers in CI4

4 min read
Load and use CI4 helpers (url, form, text, array) and create reusable custom helper files.

Helpers in CI4

// Load helpers
helper("url");      // url(), site_url(), base_url(), redirect()
helper("text");     // word_limiter(), character_limiter(), ellipsize()
helper("form");     // form_open(), form_input(), form_submit()
helper("date");     // now(), human_to_unix(), unix_to_human()
helper("array");    // array_from_prefix(), dot_array_search()
helper("security"); // sanitize_filename(), strip_image_tags()

// Auto-load helpers — app/Config/Autoload.php
public array $helpers = ["url", "form", "text"];

// Create custom helper — app/Helpers/my_helper.php
function format_phone(string $phone): string {
    return preg_replace("/(d{3})(d{3})(d{4})/", "$1-$2-$3", $phone);
}

// Use in controller or view
helper("my");
echo format_phone("5551234567");  // 555-123-4567