I'm having some difficulty finding what I'm doing wrong.
I was writing a Wordpress theme for a client that works fine on my end, but when the client tries it out they get an parsing error that I can't seem to fix since I'm not even sure what the issue is.
The line of code where the error occurs is:
<div class="custom-image" style="background-image:url( <?php echo get_option('hi_theme_options')['image_upload']; ?> );"></div>
The error they get says this:
Parse error: syntax error, unexpected '[', expecting ',' or ';'
I have tried to get my server to give me more strict error parsing but I can't get this error on my end and for that reason I'm having problems debugging and fixing the error.
(This should be happening for everyone as PHP is server-based and is not affected by the client. Make sure you are reproducing the error using the exact steps your client's end.)
Looks like you are doing array dereferencing. This is only available in PHP 5.4+. Check your version of PHP to verify you are running that version.
Like it has been pointed out here the client is using a different version of PHP than I am. So the correct way would be to create a variable that holds the functions return values and select the array value from it.
<?php
$hioptions = get_option('hi_theme_options');
print($hioption['image_upload']);
?>