0

Im just wondering if theres a recommended syntax validator out there anybody can recommend?

Having major issues and cant figure it out...

    <?php 
    session_start();
       if (isset ($_SESSION['id'])) {header("location: home.php");} 
       if (array_key_exists("login", $_GET)){$oauth_provider = $_GET['oauth_provider'];
       if ($oauth_provider == 'twitter')
       {
           header("Location: login-twitter.php");
       }  
       else if ($oauth_provider == 'facebook'){
           header("Location: login-facebook.php");
       }
       }
    ?>

 <a href="?login&oauth_provider=twitter">Twitter_Login</a>
 <a href="?login&oauth_provider=facebook">Facebook_Login</a>
5
  • 1
    If it was a syntax issue the odds are an error would be thrown by the php parser. Commented Apr 7, 2012 at 19:53
  • 1
    it's also a good idea to layout your code so it's more easily read (with indentation etc), it makes finding unhelpful error message causes more easily done. See this for an example using your provided code example: codepad.org/Q4ld9Cc6 Commented Apr 7, 2012 at 19:54
  • 1
    Not an answer to you rquestion, but a possible bug in your script: You should put an exit after the header, otherwise the rest of the script wil run too. Doesn't need to be a problem, but might be if you do database stuff in there. Anyway, just a headsup :) Commented Apr 7, 2012 at 19:56
  • Off-topic, for Liam: I just commented against your most recent question, but you deleted it in the meantime. This isn't best practice for that very reason - if you want to migrate a question to Programmers then use the 'flag' option and ask the moderator to do it for you. Sorry Sergio was rude to you - one needs tough skin for StackOverflow! :-( Commented Apr 8, 2012 at 16:39
  • Thanks @halfer I didnt realise the programmers section was for that purpose, He did make sense saying give it a go and see what happens however, thanks again :) Commented Apr 8, 2012 at 16:44

1 Answer 1

4

php -l on the command-line will do a syntax check

codepad.org is an easy way to test code online.

Your example code does not contain syntax errors: http://codepad.org/0diycu9o

Sign up to request clarification or add additional context in comments.

1 Comment

If one use not IDE, but some light editor like Scite, it is useful to set up compile/build command to something like php -l %file% into editor.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.