Fatal error: [] operator not supported for strings

This error is usually caused when you are trying to use the square brackets [] to access a character in a string, but this is not supported in PHP.

For example, the following code will trigger this error:

<?php

$str = "Hello, world!";
echo $str[0];

To access a character in a string, you can use the substr() function instead:

<?php

$str = "Hello, world!";
echo substr($str, 0, 1);  // prints "H"

Alternatively, you can use the charAt() function if you are using JavaScript:

Example of accessing a character in a string with charAt() function in Javascript
var str = "Hello, world!"; console.log(str.charAt(0)); // prints "H"