Problems in "Hello, world!" in PHP

-1

It sounds like a joke, but it's a fact. I made my first code in PHP and tested it, but it did not work out what I expected. See the image with the windows of the programs used in this test.

Insummary,Idonotknowwhyinsteadofprinting1st>HWitprintedHW"; ?> in chrome. It even seems to interpret <?php echo "1st > as an unknown code and prints what follows.

Additionally, I tested it on internet explorer and it just shows the file code, does not execute it. Anyone can explain to me what I did wrong in this "hello world"?

    
asked by anonymous 13.11.2017 / 22:01

1 answer

4

Or have you misconfigured Apache in httpd.conf (since this version you use from Xampp is old, you might have done this and you do not remember), or you saved nodepad.exe the document as Unicode or Unicode big endian :

Thisencodingwillnotwork,savethedocumentsasANSIandthenshouldworknormally.

Itestedmyself,savedasUnicodebigendianinadocumentwiththefollowingcontent:

  

IalsotestedUnicodeandthesamethinghappened

Teste:<?phpecho'oi';?>

andtested:

  

Whenopeningview-sourcethisisdisplayed:

  

Inotherwords,thePHPinterpretercannotunderstandhowitwasANSI(or"approximate"), after saving as ANSI I tried again and it worked:

  

Alternativestonodepad.exe

Notepad.exeisverylimited,todaywehavealternativesthatcanserveyoubetteras:

  • Notepad++: link
  • SublimeText: link

I left some suggestions for SublimeText settings with PHP:

13.11.2017 / 22:21