0

I use for PHP-coding Aptana Studio.

The following line gives me a syntax-error in Aptana-Studio:

<?php 
   if(isset($GLOBALS['errorSaveProfile'])) echo "<p>$GLOBALS['errorSaveProfile']</p>";
?>

But i don't understand why?

krokvskrok
  • 197
  • 2
  • 10
  • Specifically in the linked question, [this answer `Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE`](http://stackoverflow.com/a/13935532/541091) – Michael Berkowski Aug 15 '14 at 19:55

3 Answers3

3

Don't use single quotes in double quotes for array keys: echo "<p>$GLOBALS[errorSaveProfile]</p>";

There are different correct ways:

print $_GLOBALS['errorSaveProfile'];
print 'something '.$_GLOBALS['errorSaveProfile'].' something';
print "something {$_GLOBALS['errorSaveProfile']} something";

See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double and http://php.net/manual/en/language.types.string.php#language.types.string.parsing.simple

MrTux
  • 32,350
  • 30
  • 109
  • 146
1
if(isset($GLOBALS['errorSaveProfile'])) {
echo "<p>$GLOBALS[errorSaveProfile]</p>";
}
Branko Sego
  • 780
  • 6
  • 13
0

try

echo "<p>"; echo $GLOBALS['errorSaveProfile']; echo "</p>";
Fappie.
  • 482
  • 6
  • 18