search

Home  >  Q&A  >  body text

The PHP code is not executed, but the code is displayed in the browser source code

<p>I tried executing some PHP code on the project (using Dreamweaver) but the code didn't run. </p> <p>When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache runs fine (I'm using XAMPP) and the PHP page opens correctly, but the PHP code is not executed. </p> <p>Does anyone have any suggestions on what's going on? </p> <p><strong>Note: </strong>The file has been named <code>filename.php</code></p> <p><strong>Edit:</strong> Code..:</p> <pre class="brush:php;toolbar:false;"><? include_once("/code/configs.php"); ?></pre>
P粉914731066P粉914731066487 days ago736

reply all(2)I'll reply

  • P粉043566314

    P粉0435663142023-08-24 09:48:37

    php7:

    sudo a2enmod proxy_fcgi setenvif
    sudo a2enconf php7.0-fpm
    sudo service apache2 restart

    reply
    0
  • P粉604669414

    P粉6046694142023-08-24 00:59:22

    It sounds like there is something wrong with your configuration, you can check the following:

    1. Make sure PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run php -v from the command line and see if version information or any errors are returned.

    2. Make sure the PHP module is listed and uncommented in Apache's httpd.conf, this should look like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Search for LoadModule php and make sure it is not preceded by a comment (;).

    3. Make sure that the PHP MIME type is included in Apache's httpd.conf file. This should look like AddType application/x-httpd-php .php. This tells Apache to run the .php file as PHP. Search for AddType and make sure there is an entry for PHP, and that is uncommented.

    4. Make sure your file has the .php extension, or the extension specified in the MIME definition in point #3, otherwise it will not execute as PHP.

    5. Make sure you are not using short tags in PHP files (), these are not enabled by default on all servers , and their use is discouraged. Use instead (or if you have code that relies on short tags, use short_open_tag=On to enable short tags in php.ini).

    6. Make sure you use a URL like http://localhost/file.php to access the file through a web server and not through a local file file://localhost/ www/ file.php

    Finally check out the PHP manual for more setup tips.

    reply
    0
  • Cancelreply