Parse Error in PHP [closed]
-
11-09-2019 - |
Question
The following code:
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$self = $_SERVER['PHP_SELF'];
?>
Generates this error:
Parse error: syntax error, unexpected $end in /home/idghosti/public_html/testground/mma/include/header.php on line 26
What is wrong with my code?
Solution
You are missing the closing brace "}" after the statement:
$self = $_SERVER['PHP_SELF'];
It should be:
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$self = $_SERVER['PHP_SELF'];
}
?>
OTHER TIPS
You're missing a "}" before the end.
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST')
{
$self = $_SERVER['PHP_SELF'];
} // This is missing
?>
You are most likely missing a curly bracket.
Your code should be:
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$self = $_SERVER['PHP_SELF'];
}
?>
You need to close the curly bracket "}" before closing the php tag "?>"
You got a curly bracket too much...
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST')
$self = $_SERVER['PHP_SELF'];
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow