The PHP code is not executed, but the code is displayed in the browser source code
P粉914731066
P粉914731066 2023-08-23 16:04:27
0
2
615
<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粉914731066
P粉914731066

reply all(2)
P粉043566314

php7:

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

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!