Question:

Why am I getting this parse error?

by  |  earlier

0 LIKES UnLike

I am just learning to code PHP and I have written this simple program:

<?php

$answer='xbox360'

echo ('What is the best system ever?'. $answer)

if ($answer == 'xbox360')

{

echo ('have you played pray yet? It rocks!');

}

else

{

echo ('all other systems suck)');

}

?>

When run in a browser i get the parse error:

Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\phpvt\lesson 5\functions.php_phpd_tmp34.php on line 3

What is wrong with the code?

 Tags:

   Report

2 ANSWERS


  1. You have no delimiter on the first line, a mistaken delimiter on the second line, an extra parenthesis at the last echo statement. But your syntax is a total mess in any event

    &lt;?php

    $answer = &quot;xbox360&quot;;

    echo &quot;What is the best system ever?&quot;;

    if ($answer == &quot;xbox360&quot;) {

    echo &quot;have you played pray yet? It rocks!&quot;;

    }

    else {

    echo &quot;all other systems suck&quot;;

    }

    ?&gt;


  2. im not really a PHP guy, but i think your missing a semi colon on line 3 after )

    &lt;?php

    $answer=&#039;xbox360&#039;

    echo (&#039;What is the best system ever?&#039;. $answer);

    if ($answer == &#039;xbox360&#039;)

    {

    echo (&#039;have you played pray yet? It rocks!&#039;);

    }

    else

    {

    echo (&#039;all other systems suck)&#039;);

    }

    ?&gt;

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.