stijn0713 Posted April 10, 2012 Share Posted April 10, 2012 i dont understand why the it gives me a syntax error when i type this: echo '<h2> <?php echo $_POST['firstname'] ?> gelukt!</h2>'; Apparently, i have to do this: echo '<h2> <?php echo $_POST["firstname"] ?> gelukt!</h2>'; Link to comment https://forums.phpfreaks.com/topic/260695-syntax-error-with-quotations/ Share on other sites More sharing options...
xyph Posted April 10, 2012 Share Posted April 10, 2012 Single quotes: echo '<h2>'.$_POST['firstname'].' gelukt!</h2>'; Double quotes echo "<h2>{$_POST['firstname']} gelukt!</h2>"; Further reading: http://php.net/manual/en/language.operators.string.php http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double Link to comment https://forums.phpfreaks.com/topic/260695-syntax-error-with-quotations/#findComment-1336169 Share on other sites More sharing options...
Jessica Posted April 10, 2012 Share Posted April 10, 2012 Well for one, you are echoing and then putting php commands inside of that. i don't think you mean to do that. echo '<h2> <?php echo $_POST['firstname'] ?> gelukt!</h2>'; vs echo '<h2>'.$_POST['firstname'].' gelukt!</h2>'; Link to comment https://forums.phpfreaks.com/topic/260695-syntax-error-with-quotations/#findComment-1336203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.