1

I am not sure why it's not working in server. It works in local server.

I have this code:

$test="<head><meta http-equiv='Content-Type' content='text/html; charset=euc-jp'>";

and I get

syntax error, unexpected 'Content' (T_STRING) in /home/public_html/php/contact-me.php on line 2

My server php version is: 7.1.23

Thank you.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Hkm Sadek
  • 2,987
  • 9
  • 43
  • 95
  • please show the whole code til there. I guess the mistake is in line 1 (a not closed `'`) – Jeff Oct 23 '18 at 00:02
  • @jeff this is the full code `"; ?>` – Hkm Sadek Oct 23 '18 at 00:06
  • this is the full code `"; ?>` – Hkm Sadek Oct 23 '18 at 00:20
  • 1
    I can't reproduce this. Check to see if you don't have some (hidden) unicode in a code editor / hex mode. Edit: This is covered in the possible duplicate posted/flagged by @Jeff – Funk Forty Niner Oct 23 '18 at 00:22
  • My guess is you are missing a double quote in a previous piece of code, what that would do is end the string at the double quote it encounters, which will leave you with `Content` as an unquoted string (as far a PHP is concerned). – ArtisticPhoenix Oct 23 '18 at 00:26
  • @ArtisticPhoenix There's only 2 lines; look at the error: `syntax error, unexpected 'Content' (T_STRING) in /home/public_html/php/contact-me.php on line 2` < Plus, the also stated in comments that that was their full code. – Funk Forty Niner Oct 23 '18 at 00:26
  • 1
    ok @FunkFortyNiner you were right. it was ecoding. Though I saved the file with single qoute `''` the file were saved as `"" double quote` I then forced to utf-8 encoding and tried again. It worked. Many thanks. you can post it as answer.. – Hkm Sadek Oct 23 '18 at 00:28
  • 1
    @sadek I used the duplicate flagged by Jeff to close it. Thanks anyways, I'm just glad that this was resolved. And you're welcome, *cheers* :-) – Funk Forty Niner Oct 23 '18 at 00:29
  • 1
    The curly quotes can have the same effect (because they would leave it partially quoted, or un-closed) [For Example](http://sandbox.onlinephpfunctions.com/code/93f5c4e110fbb456d9747da8828f61f4e76deb14) That sand box link, with a missing quote, produces the same exact error you had (which was my point). – ArtisticPhoenix Oct 23 '18 at 00:30

0 Answers0