-1

I have two lines and do not know how can insert them to PHP tag:

    echo'<label for='body'>توضیحات: </label> <br />';
    echo'<textarea name="body" id="body" cols="" rows="" style="width:300 ;height:300"></textarea>';

These lines have the error:

( ! ) Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\source\action_perfomed_agree.php on line 64

64 is first line in my quoted code above.

Martin
  • 22,212
  • 11
  • 70
  • 132
sammy
  • 717
  • 4
  • 13

4 Answers4

3

Dont forget to escape your quote in your first echo into the using backslash like below:

Try like this :

  echo'<label for=\'body\'>توضیحات: </label> <br />';
  echo'<textarea name="body" id="body" cols="" rows="" style="width:300 ;height:300"></textarea>';
Nirnae
  • 1,315
  • 11
  • 23
  • `'` is not a valid enclosure for an HTML attribute. Use `"` - also you don't need to escape anymore. – pmayer Nov 05 '15 at 14:00
  • 2
    @PatrikMayer Of course it is. Why do you think that? HTML will accept enclosures in `'` or `"` – Ben Nov 05 '15 at 14:00
  • 2
    @PatrikMayer It works, try it. – Styphon Nov 05 '15 at 14:00
  • A backslash is untidy and fiddly to implement, it would be more logical and tidier and easier to read if simply to use the alternative quote, the double quote as in line 65, underneath. – Martin Nov 05 '15 at 14:03
  • I just explained him where was his error and how to correct it, in the end even if I agree with you on the fact that using double quote is more approriate, I wanted to keep the code as it was. – Nirnae Nov 05 '15 at 14:05
  • Ok. obviously you are right: http://stackoverflow.com/questions/273354/are-single-quotes-allowed-in-html. I took that "knowledge" from XHTML where it is not allowed. Nevertheless, with double quotes you don't need to escape. – pmayer Nov 05 '15 at 14:06
  • thank you @Nirnae, i voted you but choosed one that is more clear. thank you bro... – sammy Nov 05 '15 at 14:13
2

You are forgetting to escape your quotes.

echo'<label for=\'body\'>توضیحات: </label> <br />';

However, why not follow the same convention you used in the second line using double quotes?

echo'<label for="body">توضیحات: </label> <br />';
ddavison
  • 28,221
  • 15
  • 85
  • 110
0

You can use single quote and double quote, for example;

    echo "<label for='body'>توضیحات: </label> <br />";

or

    echo'<label for="body">توضیحات: </label> <br />';

Performance is best encapsulated by single quotes (')

juporag
  • 773
  • 3
  • 9
0

Try this:

 echo "<label for='body'>توضیحات: </label> <br />";

 echo "<textarea name='body' id='body' cols='' rows='' style='width:300px ;height:300px;'>
Deepu Sasidharan
  • 5,193
  • 10
  • 40
  • 97