I have this error Uncaught SyntaxError: Unexpected end of input but i don’t understand why.
<!DOCTYPE html>
<html>
<head>
<title>Esempio e-Cart</title>
<script src="jsFunctions.js">
</script>
</head>
<body>
<?php
for($i=0;$i < 10; $i++){
echo "<div id=\"".$i."\"><br>\n";
//on the next line is the error
echo "<button type=\"button\" onclick=\"addToCart(\"".$i."\")\">Aggiungi al Carrello</button><br>\n";
echo "</div><br>\n";
}
?>
</body>
</html>
“Unexpected end of input” = “You forgot to close a control block somewhere.”
This code as displayed does not generate a PHP error.
I have never liked using a backslash to delimit variables and double quotes and prefer string concatenatation because it is easier to spot syntax errors:
<?php
echo '<button type="button" onclick="addToCart('
. $i .')">'
. 'Aggiungi al Carrello'
. '</button><br><br>'
. "\n";
1 Like
system
Closed
September 17, 2018, 4:10pm
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.