CODE
Foreach Loop
修复非法串偏移PHP
foreach ($LS::getBase() as $base) {
$fromDatabaseThumb = $base['base-thumbnail'];
$fromDatabaseDescription = $base['base-description'];
$fromDatabaseTitle = $base['base-title'];
echo "
<div style='background-color: #ffffff; width: 725px; height: 280px; display: inline-block; position: relative;''>
<div style='display: inline-block; max-width: 450px; max-height: 260px; margin: 12px; float: left;' class='baseThumb'>
<img src='$fromDatabaseThumb' style='max-width: 450px; max-height: 260px'>
</div>
<div class='baseInfo' style='display: inline-block; width: 250px; height: 253px; margin-top: 12px;'>
<h3 style='margin: 0; font-family: helvetica; max-width: 250px; max-height: 22px; overflow: hidden;'>$fromDatabaseTitle</h3>
<p style='margin-top: 8px; word-wrap: break-word;'>
<strong>Description:</strong><br>
" . $fromDatabaseDescription . "
</p>
</div>
</div>
";
}
getBase()
功能
public static function getBase($what = '*') {
self::construct();
if(is_array($what)){
$columns = implode("`,`", $what);
$columns = "`{$columns}`";
}else{
$columns = $what != "*" ? "`$what`" : "*";
}
$sql = self::$dbh->prepare("SELECT {$columns} FROM baselayouts");
$sql->execute();
$data = $sql->fetch(\PDO::FETCH_ASSOC);
if(!is_array($what)){
$data = $what == "*" ? $data : $data[$what];
}
return $data;
}
的错误:
我做了什么
我已经做了研究,但没有找到任何工作。所以我修改了一下我的代码,仍然无法修复它。
EXTRA信息
我做了的var_dump(),因为我在面临同样的问题,因为我做了的var_dump(),所以我想我会做它只是其他帖子看到万一这样会以任何方式帮助你们。
var_dump()
array(4) {
["id"]=> string(1) "1"
["base-title"]=> string(14) "Base Layout #1"
["base-thumbnail"]=> string(24) "/res/img/baseLayout1.png"
["base-description"]=> string(73) "This is the base test description. Hopefully it does what it needs to do."
}
什么行恰好是16-18? **编辑**想通了,你可以做'var_dump($ LS :: getBase());'在你的foreach循环之前? –
@ iam-decoder是16-18。 **编辑**好吧,让我现在就这样做。 – RepeaterCreeper
@ iam-decoder它给了我和上次一样的var_dump()结果。 – RepeaterCreeper