Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I wrote a code that worked perfectly fine, but then I reinstalled my operating system, and now when I try to run this, I keep getting this error. I am using IIS 8.0, WebMatrix, and PHP 5.3.

This is the piece of code in question:

<?php 
     if (!$me->get_details()['quote']) : //<--error is here
?>
     <p class="quote">Write some motivational quote.</p>
<?php
     else :
?>
     <p class="quote"><?= $me->get_details()['quote']?></p>
<?php endif; ?>

Function get_details() returns an associative array with data from the database.

What could possibly go wrong here?

share|improve this question

marked as duplicate by John Conde Jul 18 '14 at 18:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Check your PHP version and check array dereferencing in the manual –  PeeHaa Jul 18 '14 at 18:51

1 Answer 1

You cannot dereference in PHP 5.3 this way.

You need to do:

$result = $me->get_details();

if (!$result['quote']) : 
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.