🔥 CodeIgniter
Beginner
What is the base_url() function in CodeIgniter?
Answer
The base_url() function returns the base URL of your application as configured in app/Config/App.php ($baseURL). Example: if your app is at https://example.com, then base_url("assets/css/style.css") returns https://example.com/assets/css/style.css. Use it in views for links and asset URLs: <link href="<?= base_url("css/style.css") ?>">. Related helper: site_url() prepends the index file if used. current_url() returns the full URL of the current page. previous_url() returns the referring URL. Always use these helpers rather than hardcoding URLs, so the app works regardless of where it is deployed (subdirectory, different domain, etc.).