用CSS格式化PHP麻烦

时间:2012-05-31 13:26:37

标签: php css

这个代码有什么问题,PHP现在没有显示我添加了css?

$args = array(       
'meta_key' => 'anniversary_date',     
 'meta_value' => 0,   
 );    
$user_query = new WP_User_Query( $args );   
 $users = $user_query->get_results();    

 foreach( $users as $user ):      
echo "<div class=\"anniversary-output\">"$user->display_name"</div>";    
 echo "<div class=\"anniversary-output\">will be celebrating their anniversary on </div>";       
echo "<div class=\"anniversary-output\">" get_user_meta( $user->ID, 'anniversary_date', true )"</div>";     
 endforeach;   

3 个答案:

答案 0 :(得分:1)

<?php
$args = array(
    'meta_key' => 'anniversary_date',     
    'meta_value' => 0  
);

$user_query = new WP_User_Query( $args );   
$users = $user_query->get_results();    

foreach( $users as $user ) {
    echo '<div class="anniversary-output">'.$user->display_name.'</div>';
    echo '<div class="anniversary-output">will be celebrating their anniversary on</div>';       
    echo '<div class="anniversary-output">'.get_user_meta($user->ID,'anniversary_date',true).'</div>';     
}

答案 1 :(得分:0)

你的php中有几个错误:

数组中的额外逗号&amp;没有concat .

<?php 
$args = array(       
'meta_key' => 'anniversary_date',     
'meta_value' => 0);    
$user_query = new WP_User_Query( $args );   
$users = $user_query->get_results();    

 foreach( $users as $user ):      
   echo "<div class=\"anniversary-output\">".$user->display_name."</div>";    
   echo "<div class=\"anniversary-output\">will be celebrating their anniversary on </div>";       
   echo "<div class=\"anniversary-output\">".get_user_meta( $user->ID, 'anniversary_date', true )."</div>";     
 endforeach; 
?>

答案 2 :(得分:0)

我添加了连接。试试这个

echo "<div class=\"anniversary-output\">".$user->display_name."</div>";    
echo "<div class=\"anniversary-output\">will be celebrating their anniversary on </div>";       
echo "<div class=\"anniversary-output\">".get_user_meta( $user->ID, 'anniversary_date', true )."</div>";