John Davidson

codeigniter - PHP 7.4 CI 3 short echo tag throw exception while loading CI view

0 comments
Message:


<?= $this->load->view('test_view.php', []); ?>

Above load view is working fine till PHP 7.3 but after upgrading to PHP 7.4, it throws exception Object of class MY_Loader could not be converted to string.


It make sense, its a shorthand for echo not object but curiosity is why it was working in PHP 7.3 ?



My Answer:
In PHP 7.3, the short echo tag `` was still supported for echoing out values. However, in PHP 7.4, the short echo tag is deprecated and will be removed in future versions of PHP.

To fix the issue, you can simply replace `` with `` in your code:

php
load->view('test_view.php', []); ?>


This should resolve the exception and allow your code to work properly in PHP 7.4.

Rate this post

3 of 5 based on 8523 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us