Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.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 将多个变量回送到一个div类_Php - Fatal编程技术网

Php 将多个变量回送到一个div类

Php 将多个变量回送到一个div类,php,Php,我试图回显我所做的IF语句中的用户名和问候语 <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 64 ); $hour = date('G'); if ($hour < 12) {

我试图回显我所做的IF语句中的用户名和问候语

<?php
                global $current_user;
                get_currentuserinfo();
                echo get_avatar( $current_user->ID, 64 );
                $hour = date('G');
                if ($hour < 12) {
                    $greeting = 'Good Morning';
              } else if ($hour < 18) {
                    $greeting = 'Good Evening';
              } else {
                    $greeting = 'Good Night';
        }

    echo '<div class="greeting">'.($greeting). , .$current_user->user_login. '</div>';
?>

但我发现语法错误:

语法错误,意外“,”


如何将两个变量回显到一个div中?

您的逗号应包含在字符串中:

echo '<div class="greeting">'.$greeting.' , '.$current_user->user_login. '</div>';
echo'.$greeting'.,'.$current\u user->user\u login';

逗号应包含在字符串中:

echo '<div class="greeting">'.$greeting.' , '.$current_user->user_login. '</div>';
echo'.$greeting'.,'.$current\u user->user\u login';

即使是本网站的语法突出显示也会告诉您,出了什么问题;)哪根线看起来不像另一根?提示:错误消息中提到了它。甚至这个站点的语法突出显示也会告诉您,出了什么问题;)哪根线看起来不像另一根?提示:错误消息中提到了它。