PHP only shows codes

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP only shows codes

Postby obeastyo » 22. August 2020 17:22

Whenever i open my PHP it only shows the codes even if my file is saved on htdocs. The mysql is also on as well. PLEASE SEND HELP :( :( :(
obeastyo
 
Posts: 2
Joined: 22. August 2020 17:18
XAMPP version: 7.4.8
Operating System: Windows

Re: PHP only shows codes

Postby Altrea » 22. August 2020 19:52

95% of these issues are because the coder tries to open the file directly in the browser (e.g. by double click or the open dialogue in the browser).
PHP files need to get processed by an interpreter and that will only happen if you request the file from a webserver.
So your url should start with something like http://localhost/
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 10342
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP only shows codes

Postby obeastyo » 23. August 2020 06:53

Yes my URL starts at localhost but it still shows codes instead
obeastyo
 
Posts: 2
Joined: 22. August 2020 17:18
XAMPP version: 7.4.8
Operating System: Windows

Re: PHP only shows codes

Postby Altrea » 23. August 2020 07:20

Then please check if your php code starts with
Code: Select all
<?php
, short open tags
Code: Select all
<?
are not activated by default.

Please check that your php file has the file extension .php
.html files will not get parsed by the php interpreter.

And please check that the character encoding of the file is ANSI compatible (e.g. ISO-8859 or UTF-8 are the most common ones). Especially multi byte encodings like UCS2 big endian cannot get parsed by the php interpreter.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 10342
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 135 guests