PHP Fatal error: Uncaught Error: [] operator not supported for strings

PHP Fatal error: Uncaught Error: operator not supported for strings



I realise that this question has been asked a number of times but I am yet to find a solution to this problem.



I am using pChart (pData v2.1.4). It works fine on the hosting site which is running php v5.6.30 but I getting a fatal error with the same code on XAMMP which is running php v7.2.5.



The error refers to this line in pData: (NOTE: pData is a class written by a third party and so not my code)


function convertToArray($Value)
$Values = ""; $Values = $Value; return($Values);



Any suggestions as to how to resolve the problem? I have tried declaring $Values as an array earlier in the code but this seemed to cause more errors.



Also, is this php version related and an error that I am going to start getting if my hosting site moves on to a newer version php?




4 Answers
4



You can't convert string to array ($Values = ""; $Values = $Value;), so right variant:


$Values = ""; $Values = $Value;


function convertToArray($value)
return [$value];



You have declared $Values as string:


$Values


$Values = "";



Fix replacing with array:


function convertToArray($Value)

$Values = ;
$Values = $Value;
return $Values;



But, in my opinion, there is no reason to use this function.
In your code, just define an array of the same variable with:


$Value = [$Value];



It will do the same as your function.



Try this,


function convertToArray($Value)
$Values = array(); // initialize

if ( isset($Value) ) $Values = $Value;

return($Values);



Let me know if it works or not.



Values should declared as Array Try this.


function convertToArray($Value)
$Values = ;
$Values = $Value;
return $Values;






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

ᵟᴈ,ᴘᵨᵷᴬ ᴳᵵᴂᴮᵇᵘᴀᴈᴵᵪᵬᴵᴬᴢᵔᵧ,ᵄᴠᴹᵔᴍᵲᵜᴫᵄᵋᴅ,ᵪᵢᵠ ᴡᵗ,ᵷᴝᵲ ᴖᴤᵡ,ᴎ,ᴚ ᵡᵪᵀ,ᴐᵉ,ᵿᴂ,ᴽᴽᵍᵟᵍᴠᵓᵯᴞᵅᵛᵢ,ᴐᴁ ᵺᴉᵸᴵᴶᵄᴪᵷ,ᴌᴠᴗᴚ,ᵟᵺᵳᴝᴉᴰ,ᵹᵥ ᵂᴴ,ᴵ,ᵉᵿ ᴕᵕ,ᴃᴡᴒᵐᴇᴳᵅᵞᴒᴝᴳᴋᴗᵢᵶᵢᵅᴣᴑᵘᵷᵾᴍᴔᴵ,ᴢᴘ,ᴮᵫᴘ,ᵳ,ᴩᵓᴞ