I currently have some code in my HTML page such as:
<a href="examplecode/sample.php">Click here to view this PHP code sample.</p>
The problem is that my web page is also written in PHP, so when the file is clicked the PHP code runs, which is not what I want: I want the code to be simply displayed in the web browser, and I want it to be possible to download the file. How should I proceed? I would prefer a solution where I do not have to change the .php
file extension. Thanks.
NOTE: I've tried the solution outlined here. I've included the following line:
php_flag engine off
in my .htaccess
file. However, if I place the .htaccess
file in the examplecode
directory, the PHP code runs, and if I place it in the directory above where index.php
is found, then none of the PHP files in that root directory run. How can I solve this issue?