Illegal string offset Warning PHP |
X

Congrats, You are Subscribed to Receive Updates.

Illegal string offset Warning PHP


Illegal string offset Warning PHP. Whenever you see this error. you will feel that its messed up our code. But its a simple mistake we did it on the array of parameter.  Normally we have an array with key and its value as like the following one.

<?php 
$test_array = array(
          'first_key'  => 'first',
          'second_key' => 'second',
          'third_key'  => 'third',
          'four_key'   => 'four'
);
?>

Here the above array has some values. But when you call this array with not set parameter it will throw an illegal offset parameter like the following one.

<?php if($test_array['fifth_key'] != 0 ){
    //some code
   }
?>

for such a kind of issues, we can use this way.

<?php if(isset($test_array['fifth_key'])){
         if($test_array['fifth_key'] != 0 ){
            //some code
         }
   }

Here the ” isset ” function will help use to solve this error.

 

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar