CodeIgniter Forums
[SOLVED]Error: A non-numeric value encountered - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: [SOLVED]Error: A non-numeric value encountered (/showthread.php?tid=78570)



[SOLVED]Error: A non-numeric value encountered - alakian - 02-09-2021

I have this code:

PHP Code:
    public function pricesListByAjax()
    {
        if(
$this->request->isAJAX()){
            
$html ''// Line 395
            
$html += '<div>';
            
$html += '<div class=""></div>';
            
$html += '</div>';
            return 
$html;
        }
    } 

But in action I see this error:

PHP Code:
    "title""ErrorException",
    "type""ErrorException",
    "code"500,
    "message""A non-numeric value encountered",
    "file""C:\\MAMP\\htdocs\\ci4\\app\\Controllers\\ProductController.php",
    "line"395


how do can I fix this error?


RE: Error: A non-numeric value encountered - kenjis - 02-09-2021

See Line 395 in C:\\MAMP\\htdocs\\ci4\\app\\Controllers\\ProductController.php.


RE: Error: A non-numeric value encountered - alakian - 02-09-2021

(02-09-2021, 01:34 AM)kenjis Wrote: See Line 395 in C:\\MAMP\\htdocs\\ci4\\app\\Controllers\\ProductController.php.

Line 395:

Code:
$html = ''; // Line 395



RE: Error: A non-numeric value encountered - kenjis - 02-09-2021

Not `$html += '<div>';`
But `$html .= '<div>';`


RE: Error: A non-numeric value encountered - alakian - 02-09-2021

(02-09-2021, 01:38 AM)kenjis Wrote: Not `$html += '<div>';`
But `$html .= '<div>';`


Thanks Fix it.