显示联机用户数以及他们正在浏览的页面


Displaying the number of users online and the page they are browsing

当我打开页面时,它返回:

分析错误:语法错误,意外的T_VARIABLE,应为"、"或";"in/home/a1361025/public_html/9/9/functions.php,第44行

这是44号线

echo "$count. ($useronline[ip]) Browsing page: <a href="$useronline[page]">$useronline[page]</a>";

只需尝试:

echo $count . ' (' . $useronline['ip'] . ') Browsing page: <a href="' . $useronline['page'] . '">' . $useronline['page'] . '</a>';

如果你不想让引号结束你的字符串,你必须转义引号:

echo "$count. ($useronline[ip]) Browsing page: <a href='"$useronline[page]'">$useronline[page]</a>";

结束字符串,然后直接粘贴一个变量:

echo "$count. ($useronline[ip]) Browsing page: <a href="$useronline[page]">$useronline[page]</a>";
//                                                     ^^^^^^^^^^^^^^^^^^^

您需要用反斜杠对它们进行转义(因为您在双引号中使用双引号):

echo "$count. ($useronline[ip]) Browsing page: <a href='"$useronline[page]'">$useronline[page]</a>";
//                                                     ^                  ^