CodeIgniter Forums
CodeIgniter 4 base_url() bug - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: CodeIgniter 4 base_url() bug (/thread-79119.html)



CodeIgniter 4 base_url() bug - Muzikant - 04-22-2021

If I will add a file parameter to base_url() function, it will add an equal sign (=) to the end, which should not be there. I am considering this as a bug. I tested it in PHP 7.4 and 8.

The code

PHP Code:
echo base_url('favicon.ico' '?' 'v101'); 

will output

Code:
http://localhost/favicon.ico?v101=

I am using these parameters to force browsers to get the new versions of a files.


RE: CodeIgniter 4 base_url() bug - iRedds - 04-22-2021

1. base_url() . 'favicon.ico' . '?' . 'v101';
2. do not use base_url()
3. base_url('favicon.ico' . '?' . 'v=101')
4. configure caching on the server.


RE: CodeIgniter 4 base_url() bug - Muzikant - 04-23-2021

(04-22-2021, 02:26 PM)iRedds Wrote: 1. base_url() . 'favicon.ico' . '?' . 'v101';
2. do not use base_url()
3. base_url('favicon.ico' . '?' . 'v=101')
4. configure caching on the server.

  1. I know, but this is not fixing a bug in the framework. My thread is not call for a help, but a bug report. There is no problem in CodeIgniter 3.
  2. Why not to use base_url()? It should be used for files instead of site_url(), like it is in the documentation.
  3. I did not get the point. This is exactly what I wrote what is causing the problem.
  4. No, it is a good practice to do it the way I am doing it to get an immediate effect. But maybe I am doing it wrong (tell me why).

(04-22-2021, 02:26 PM)iRedds Wrote: 3. base_url('favicon.ico' . '?' . 'v=101')

Oh, I get it. My mistake. I understand why it is adding an equal sign at the end now. In my case it is considered as the parameter name and expecting a value.