请帮我解释下这段php

来源:百度知道 编辑:UC知道 时间:2024/06/12 03:31:24
我在书上看到说,如果要把php插入html当中。要使用下面这段代码。
<?php
include("top.php");
?>
然后我照着做了。把top.php改为我的一个会员登陆页面的php
并把这个.html页面存为.php

但打开这个.html存为.php的页面时却看到那个会员登陆php出现警告
如下
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/XXX/domains/XXX.host9.meyu.net/public_html/index2.php on line 67

Warning: include(http://XXX.host9.meyu.net/bbs.gb2312/888.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/XXX/domains/XXX.host9.meyu.net/public_html/index2.php on line 67

Warning: include() [function.include]: Failed opening 'http://XXX.host9.meyu.net/bbs.gb2312/888.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /

所谓的“把php插入html当中”其实是两各语言的混合,是将两种语言写在同一个 php 文件中的一种做法,与 iframe 的“插入”是完全不同的,不能用 iframe 的思维去考虑 php 。
因此,
<?php
include("top.php");
?>
这种想法就是错误的!虽然在语法上是正确的!
在 PHP 中,使用 <?php 与 ?> 来分离 php 与 html 语言。include("top.php"); 就是 php 部分, <?php 与 ?> 外面可以写 html 内容。
再来看你的做法:
你“把这个.html页面存为.php”,这是完全错误的做法!.html 与 .php 是用两种语言编写的文件,不能通过修改扩展名来互相转换。

这几个警告是告诉你无法找到你引用的文件。你被引用的应该是888.php这个文件,引用的文件是index2.html。如果被引用的文件和你的引用文件在一个文件夹内,可以直接写include(888.php),如果在上级目录则需写成include(../888.php)。以此类推。