Heim  >  Fragen und Antworten  >  Hauptteil

PHP-Code wird nicht ausgeführt, sondern im Browser-Quellcode angezeigt

Ich habe versucht, PHP-Code für das Projekt auszuführen (mit Dreamweaver), aber der Code wurde nicht ausgeführt.

Wenn ich den Quellcode überprüfe, erscheint der PHP-Code als HTML-Tags (ich kann ihn im Quellcode sehen). Apache läuft einwandfrei (ich verwende XAMPP) und die PHP-Seite wird korrekt geöffnet, aber der PHP-Code wird nicht ausgeführt.

Hat jemand Vorschläge, was los ist?

HINWEIS: Diese Datei wurde filename.php

benannt

Herausgeber: Code..:

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

Antworte allen(2)Ich werde antworten

  • P粉315680565

    P粉3156805652024-01-17 09:23:04

    php7:

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

    Antwort
    0
  • P粉795311321

    P粉7953113212024-01-17 00:16:19

    听起来您的配置有问题,您可以检查以下几项:

    1. 确保 PHP 已安装并正确运行。这可能听起来很愚蠢,但你永远不知道。一种简单的检查方法是从命令行运行 php -v 并查看是否返回版本信息或任何错误。

    2. 确保 PHP 模块在 Apache 的 httpd.conf 中列出且未注释,这应该类似于 LoadModule php5_module "c:/php/php5apache2_2.dll" 在文件中。搜索 LoadModule php,并确保其前面没有注释 (;)。

    3. 确保 Apache 的 httpd.conf 文件中包含 PHP MIME 类型。这应该类似于 AddType application/x-httpd-php .php。这告诉 Apache 将 .php 文件作为 PHP 运行。搜索 AddType,然后确保有 PHP 条目,并且未注释

    4. 确保您的文件具有 .php 扩展名,或者在第 #3 点的 MIME 定义中指定的扩展名,否则它将不会作为 PHP 执行。

    5. 确保您没有使用短标签 在 PHP 文件 () 中,默认情况下,这些并非在所有服务器上启用,并且不鼓励使用它们。使用 代替(或 如果您有依赖于短标签的代码,请使用 short_open_tag=On 在 php.ini 中启用短标签)。

    6. 确保您使用类似 http://localhost/file.php 的 URL 通过网络服务器访问文件,而不是通过本地文件访问 file://localhost/ www/file.php

    最后查看PHP 手册以获取更多设置提示

    Antwort
    0
  • StornierenAntwort