How to remove the warning: Cannot use a scalar value as an array in /home/… in PHP?

To remove the warning, read the code and find the “if” statement

For Example:

if (!isset($_SESSION[‘view’][$the_ID]))

Now replace: !isset with: is_scalar

The above line will become:

if (is_scalar($_SESSION[‘view’][$the_ID]))

Save the file and run it. You will see that the warning has disappeared.

Note: !isset is just an example. It could be anything in your code. This tweak will suppress the warning.

Leave a Reply