Web 浏览器不将 PHP 代码作为 PHP 代码处理
我的计算机中安装了 Joomla,但最近一直在编写与 Joomla 管理的站点无关的 php 文件。由于某种原因,当我尝试使用 xampp 在 Web 浏览器中打开这些 php 文件时(注意:Joomla 也在使用 xampp),浏览器不会将标签中的代码处理为 php 代码。
例如,在浏览器中打开一个基本页面(标题为“test”的页面,除了body标签中没有任何内容)并转到源代码后,源代码中显示以下内容:
<body>
<?php echo "hello"; ?>
</body>
而不是HTML转换。 (即只是“你好”)
有人知道这里发生了什么吗?
谢谢。
I have Joomla installed in my computer, but recently have been writing php files that aren't related to the Joomla-managed site. For some reason, when I try to open those php files in the web browser using xampp (note: Joomla also is using xampp), the browser doesn't process the code w/in the tags as php code.
For example, after opening a basic page (a page with title "test", no content except in the body tags) in the web browser and going to the source code, the following is shows up in the source code:
<body>
<?php echo "hello"; ?>
</body>
instead of the HTML conversion. (i.e. just "hello")
Does anyone have an idea about what's going on here?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这可能是因为你的 apache 中没有加载 PHP 模块。确保它已启用
It's probably because PHP module isn't loaded in your apache. Be sure it is enabled
PHP 在服务器中解释,而不是在浏览器中解释。无论出现什么问题,您都需要查看 SERVER 端来解决它。
我的第一个猜测:也许你没有为文件添加后缀“.php”(所以服务器无法将其识别为PHP文件?)
第二个猜测:包含您的 PHP 文件的目录是否配置为解析 PHP?
如果您有 Joomla,那么您可能也有 PHP。您可能还拥有 Apache。
因此,请检查您的 Apache 配置,并检查您的文件命名约定。
PHP is interpreted in the server, not the browser. Whatever's going wrong, you need to look at the SERVER side to resolve it.
My first guess: maybe you didn't suffix the file ".php" (so the server doesn't recognize it as a PHP file?)
Second guess: is the directory containing your PHP files configured to parse PHP?
If you have Joomla, you probably have PHP. You probably also have Apache.
So check your Apache configuration, and check your file naming conventions.
文件扩展名是.php吗?服务器不会神奇地知道您何时提供 php 文件,这是确保它知道您在做什么的好方法。
Is the file extension .php? The server doesn't magically know when you're serving php files, this is a good way to ensure it knows what you're doing.
Apache 正在查找本地主机定义的根目录以查找它可以解析的文件。在本例中为 htdocs。这是 XAMPP 的默认设置。就 Apache 而言,它不会解释该文件夹之外的任何文件。
Apache is looking into your localhost's defined root directory for files it can parse. In this case htdocs. This is the default for XAMPP. As far as Apache is concerned, it will not interpret any files outside of that folder.
如果 php 模块出现问题,最好将 php5 重新安装到系统中,它将正常工作。问题可能出在 php 模块中,您应该尝试在系统中重新安装 php。
if the problem in php module it better to re install php5 in to the system and it will work fine. probably the problem is in php module you should try re installing php in your system.
只需重新启动httpd服务即可。它会工作得很好。
如果它不起作用,请重新安装 PHP。
Just restart httpd service. It will work fine.
if it has not worked please reinstall PHP once again.