Why might a PHP file only be downloadable instead of displaying the expected output when accessed on a server?
This issue may occur if the PHP interpreter is not enabled on the server, causing the server to treat the PHP file as a regular download instead of executing it. To solve this, you need to ensure that the server has PHP installed and configured properly. You can also check if the file extension is correct (e.g., .php) and that there are no syntax errors in the PHP code.
<?php
// Your PHP code here
echo "Hello, world!";
?>