使用include_once()显示的源 [英] Source Displayed With include_once()

查看:78
本文介绍了使用include_once()显示的源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚在Win XP Pro机器上安装了Apache 2.2和PHP 5.1.4。

如果我运行phpinfo(),它会正确显示所有内容。但是,在我已经包含一些包含某些功能的文件的页面上,它只需显示所包含文件的内容而不是运行

功能。例如,我有一个名为do_html_header()的函数,

正如名字所暗示的那样,我已经使用了很长一段时间了。


我页面的顶部如下所示:


<?php

include_once(" functions.php");


do_html_header(" Terms");

?>


但是,当我查看页面源代码时,实际的PHP代码显示,

不仅仅是它应该显示的HTML。似乎

PHP正确安装,因为phpinfo()工作正常。有没有其他我不想要的东西?


谢谢。


史蒂夫

I have just installed Apache 2.2 and PHP 5.1.4 on my Win XP Pro machine.
If I run phpinfo(), it displays everything correctly. However, on a
page where I have included a file that contains some functions, it
merely shows the contents of the included file instead of running the
function. For instance, I have a function called do_html_header() that
does just what the name suggests, and I''ve used it for quite a while.

The top of my page looks like this:

<?php
include_once("functions.php");

do_html_header("Terms");
?>

However, when I view the page source, the actual PHP code is displayed,
not just the HTML that it is supposed to display. It would seem that
PHP is installed correctly since phpinfo() works fine. Is there
something else I''m missing?

Thanks.

Steve

推荐答案

Steve写道:
Steve wrote:

我的页面顶部如下:


<?php

include_once(" functions.php");

do_html_header(" Terms");

?>


但是,当我查看页面源代码时,会显示实际的PHP代码,

不仅仅是它应该的HTML显示。似乎PHP

安装正确,因为phpinfo()工作正常。有什么东西

我还缺什么?
The top of my page looks like this:

<?php
include_once("functions.php");
do_html_header("Terms");
?>

However, when I view the page source, the actual PHP code is displayed,
not just the HTML that it is supposed to display. It would seem that PHP
is installed correctly since phpinfo() works fine. Is there something
else I''m missing?



似乎文件functions.php没有被解释为PHP

代码。检查您的服务器设置,确保该文件放在

合适的目录中。


另外,您可以确保包含文件开始与<?php结束

with?>。否则,PHP无法知道你的代码是什么

而不是纯文本。


HTH,

-

Benjamin D. Esham
bd*****@gmail.com |目的:bdesham128 | Jabber:和电子邮件一样

鉴于我们迟早都会死,我们学习整数是什么? ?"一个?? Calvin

It would seem that the file functions.php is not being interpreted as PHP
code. Check your server settings to make sure that the file is placed in a
suitable directory for inclusion.

Also, you might make sure that your include file begins with <?php and ends
with ?>. Otherwise, PHP has no way of knowing that your code is anything
other than plain text.

HTH,
--
Benjamin D. Esham
bd*****@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
"Given that sooner or later we''re all just going to die, what''s
the point of learning about integers?" a?? Calvin




Steve写道:

Steve wrote:

我刚刚在我的Win XP Pro机器上安装了Apache 2.2和PHP 5.1.4。

如果我运行phpinfo(),它会正确显示所有内容。但是,在我已经包含一些包含某些功能的文件的页面上,它只需显示所包含文件的内容而不是运行

功能。例如,我有一个名为do_html_header()的函数,

正如名字所暗示的那样,我已经使用了很长一段时间了。


我页面的顶部如下所示:


<?php

include_once(" functions.php");


do_html_header(" Terms");

?>


但是,当我查看页面源代码时,实际的PHP代码显示,

不仅仅是它应该显示的HTML。似乎

PHP正确安装,因为phpinfo()工作正常。有没有其他我不想要的东西?


谢谢。


Steve
I have just installed Apache 2.2 and PHP 5.1.4 on my Win XP Pro machine.
If I run phpinfo(), it displays everything correctly. However, on a
page where I have included a file that contains some functions, it
merely shows the contents of the included file instead of running the
function. For instance, I have a function called do_html_header() that
does just what the name suggests, and I''ve used it for quite a while.

The top of my page looks like this:

<?php
include_once("functions.php");

do_html_header("Terms");
?>

However, when I view the page source, the actual PHP code is displayed,
not just the HTML that it is supposed to display. It would seem that
PHP is installed correctly since phpinfo() works fine. Is there
something else I''m missing?

Thanks.

Steve



我能想到的唯一原因是,你不会在/。
中找到开头标记," ;<?"或<?php。

The only reason this would occur, that I can think of, is you don''t
have the opening tags in the functions.php file, "<?" or "<?php".


在新服务器上发生了类似的事情。这只是一个问题

用''<?php''替换''<?''。打几块钱你的情况是一样的。


-----------------------

Jussi
http://www.viewinteractive.fi
Similar thing happened to me on a new server. It was just a question of
replacing ''<?'' with ''<?php'' . Bet a few bucks your case is the same.

-----------------------
Jussi
http://www.viewinteractive.fi


这篇关于使用include_once()显示的源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆