alexgarcia Posted September 15, 2016 Share Posted September 15, 2016 Hello, I am new to programming. And in php in particular. I'm learning and I have the following error: PHP Parse error: syntax error, unexpected '{' in web.php on line 20 Can I use this? if (is_paged()) echo "Página 1"; Or I need use? if (is_paged()) echo "Página 1" }; Thanks! Quote Link to comment Share on other sites More sharing options...
Barand Posted September 15, 2016 Share Posted September 15, 2016 {..} always need to be in pairs. So both these are correct if (is_paged()) echo "Página 1"; if (is_paged()) { echo "Página 1"; } Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted September 15, 2016 Share Posted September 15, 2016 (edited) One thing to keep in mind about PHP, and other programming languages, is that the error doesn't always point to the correct line. Sometimes, the error is caused by something earlier in the script. For example, I get a similar error with the following code: <?php print 'hello' if(1) { print ' there'; } ?> PHP says there is an error on line 3. However, the actual error is on line 2, where I'm missing a semi-colon. Edited September 15, 2016 by cyberRobot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.