PHP code is not executed but shown in browser source code
P粉805107717
P粉805107717 2024-01-16 10:56:46
0
2
447

I tried to execute some PHP code on the project (using Dreamweaver) but the code did not run.

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.

Does anyone have any suggestions on what's going on?

Note: The file has been named filename.php

edit: Code..:

<?
include_once("/code/configs.php");
?>
P粉805107717
P粉805107717

reply all(2)
P粉315680565

php7:

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

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!