Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用css和外部内容将div保持在所需位置_Php_Css_Html - Fatal编程技术网

Php 使用css和外部内容将div保持在所需位置

Php 使用css和外部内容将div保持在所需位置,php,css,html,Php,Css,Html,这是我的问题 我有一个函数,PHP class side,它从一个表中读取所有数据,用特定的CSS ID创建所有div,将数据放在适当的位置,其中一个数据来自外部源,一个外部PHP文件 所以我在代码中这样做: $Return .= "</div><div id='PostTitleComplete'><strong>Post Completo</strong></div><div id='PostText'>"; $Retu

这是我的问题

我有一个函数,PHP class side,它从一个表中读取所有数据,用特定的CSS ID创建所有div,将数据放在适当的位置,其中一个数据来自外部源,一个外部PHP文件

所以我在代码中这样做:

$Return .= "</div><div id='PostTitleComplete'><strong>Post Completo</strong></div><div id='PostText'>";
$Return .= include($row['PathFile']);
$Return .= "</div><div id='PostData'>";
这是上述一项的父项:

#PostBody {
    border: #00C 1px solid;
    width:80%;
    background:#FFFFFF;
    float:left;
}
这是包含文件中的CSS: 一个div包括一个div,正如名称所示

#FirstOne {
    border: #000080 1px solid; 
    color: #000; 
    font-family: 'Courier New', Courier, Monospace; 
    font-size: 9pt;
}
#SecondOne {
    background: #000080; 
    color: #fff; 
    font-family: Verdana, Tahoma, Arial, sans-serif; 
    font-weight: bold; 
    padding: 2px 5px;
}
我在一个博客中使用了相同的结构,但是我没有使用include文件,而是使用了表中的数据,所以我认为问题来自CSS。这就是我得到的结果。这张Giang Div完全可以根据屏幕大小进行调整,但它保持在屏幕上方,而不是箭头指向的位置,并且在这里打印了include


尝试使用文件获取内容()而不是使用incude

$Return.=“发布完成后””;
$Return.=“”;
$Return.=文件获取内容($row['PathFile']);
$Return.=“”;

返回值
1
,因为
include
-语句已成功执行

如果包含的文件不包含任何需要运行的代码,则可以使用
文件获取内容()

$Return.=“发布完成后””;
$Return.=文件获取内容($row['PathFile']);
$Return.=“”;
作为参考,如果包含文件确实包含必须执行的代码,请使用输出缓冲:

function get_include_contents($filename) {
    if (is_file($filename)) {
        ob_start();
        include $filename;
        return ob_get_clean();
    }
    return false;
}
$Return .= "</div><div id='PostTitleComplete'><strong>Post Completo</strong></div><div id='PostText'>";
$Return .= get_include_contents($row['PathFile']);
$Return .= "</div><div id='PostData'>";
函数get\u include\u contents($filename){ 如果(是_文件($filename)){ ob_start(); 包括$filename; 返回ob_get_clean(); } 返回false; } $Return.=“发布完成后”; $Return.=get_include_内容($row['PathFile']); $Return.=“”;
上述代码取自

的$Return.=file_get_contents($row['PathFile']);工作得很好,谢谢
$Return .= "</div><div id='PostTitleComplete'><strong>Post Completo</strong></div>";
$Return .= "<div id='PostText'>";

$Return .= file_get_content($row['PathFile']);

$Return .= "</div><div id='PostData'>";
$Return .= "</div><div id='PostTitleComplete'><strong>Post Completo</strong></div><div id='PostText'>";
$Return .= file_get_contents($row['PathFile']);
$Return .= "</div><div id='PostData'>";
function get_include_contents($filename) {
    if (is_file($filename)) {
        ob_start();
        include $filename;
        return ob_get_clean();
    }
    return false;
}
$Return .= "</div><div id='PostTitleComplete'><strong>Post Completo</strong></div><div id='PostText'>";
$Return .= get_include_contents($row['PathFile']);
$Return .= "</div><div id='PostData'>";