Syntax error??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Evan

    Syntax error??

    Why does the following line create a Syntax error in PHP.

    $Mac = ( (strstr($query, 'Mac') || (strstr($query, 'Mc') ||
    (strstr($query, 'M ') );

  • Michael Winter

    #2
    Re: Syntax error??

    On 28/03/2005 18:53, Evan wrote:
    [color=blue]
    > Why does the following line create a Syntax error in PHP.[/color]

    The statement (it's two lines :P) has unmatched closing parentheses.
    [color=blue]
    > $Mac = ( (strstr($query, 'Mac') || (strstr($query, 'Mc')[/color]
    ^ ^ ^ ^ ^ ^ ^
    1 2 3 2 3 4 3
    [color=blue]
    > || (strstr($query, 'M ') );[/color]
    ^ ^ ^ ^
    4 5 4 3

    The digits show the number of open parentheses. As you can see, you're
    left with three by the end of the statement. I imagine that the
    opening parenthesis before each strstr function call shouldn't be there.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Evan

      #3
      Re: Syntax error??


      Thanks! Sure makes you feel dumb when you make a stupid mistake like
      that and then can't spot what is wrong!

      Evan

      Comment

      Working...