Casa > H > How To Fix This: “Warning: Illegal String Offset 'Style'”

How to fix this: “Warning: Illegal string offset 'style'”

This is most likely a PHP warning message.

This usually happens when you have a variable that holds a string, but try to access it like it was an array. Like this:

  1. = "Hello, world!"; 
  2. echo ['style']; 
  3. // PHP Warning: Illegal string offset 'style' in ... on line ... 

PHP does, in fact, allow square bracket syntax for strings; it can be used to access individual characters in a string. However, the offset (i.e. the value in square brackets) has to be an integer. For example:

  1. = "Hello, world!"; 
  2. echo [7]; 
  3. // w 

String values (like “style”) are forbidden here. That's what the error message is saying.

You probably have a typo in your code, or have your variables mixed up; or maybe you call a function that expects an array, but is passed a string instead.

Try navigating to the line indicated by the error message, find where the "style" bit is where the "style" bit. Verifique duas vezes o que toda a linha de código está fazendo, então use var_dump() ou print_r() na variável (ou valor) usada para ver o que realmente está lá dentro. Deve ficar muito mais claro uma vez que você veja os valores reais.

De Chilcote

O que devo escrever para ganhar ajuda financeira para o Coursera? :: A gameloot.in legit?