我在 PHP 中有以下内容,使用 Wordpress + Buddypress 插件:
$blogusers = get_users('role=s2member_level1&number=5');
foreach ($blogusers as $user) {
$username = str_replace('"', '',$user->user_nicename);
$fullname = str_replace('"', '',bp_profile_field_data( array( 'user_id'=>$user->ID,'field'=>'name' ) ));
$category = str_replace('"', '',bp_profile_field_data( array( 'user_id'=>$user->ID, 'field'=>'category' ) ));
echo '<div style="float:left; width:100px; height:100px;">';
echo '<h3><a href="members/' . $username . '">' . $fullname . '</a></h3>';
echo '<strong>Camp Type: </strong>' . $category . '<br />';
echo '</div>';
}
$fullname 和 $category 变量在 float:left 元素之前被碰撞,但 $username 变量保持在原位,这是所有变量应该呈现的方式。
IE:
<div class="page" id="blog-latest" role="main">
<div style="width:500px;height:100px;position:relative;">
Frank GoreType 4<div style="float:left; width:100px; height:100px;"><h3><a href="members/fgore"></a></h3><strong>Camp Type: </strong><br /></div>
</div>
有什么线索可以解释为什么这两个变量被排除在 echo 语句之外?