-2

(Edited for clarification) I am trying to execute some PHP code in a file called "index.php" using the Apache web server in XAMPP. The file is located at C:\xampp\htdocs\index.php.txt (not sure how to get rid of the .txt suffix). I am accessing the file by typing "http://localhost/index.php.txt" into my browser. The code is:

<!DOCTYPE html>
<html>
<body>
      <?php echo "It works!"; ?>
</body>
</html>

When I select the file in the Apache server only the code itself shows up. I've been searching around for a while and I can't seem to find the issue. Thanks in advance.

6
  • Check your log files Commented Mar 5, 2019 at 6:47
  • where this file is located and how you are accessing it? Commented Mar 5, 2019 at 6:49
  • 1
    This simply means that PHP isn't processing your file. Share your config file: httpd.conf Commented Mar 5, 2019 at 6:50
  • 1
    Possible duplicate of PHP not working in XAMPP Commented Mar 5, 2019 at 6:52
  • I looked around a bit. Got a "system cannot find path specified" error for the PHP error log. Can't find any PHP logs anywhere. The Apache error and access logs look fine. Commented Mar 5, 2019 at 6:58

1 Answer 1

1

Your PHP code are not executing because the server interpret the file as text file, hence why the codes are not executing. This is due to your file name, which have .txt extension.

not sure how to get rid of the .txt suffix

Use any code editor like Notepad++ to save the file as PHP file, hence getting rid of the .txt extension.

Or for normal Windows Notepad, just select save as "all file", and the file name make sure only "index.php".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.