我正在为TeamsSpeak服务器开发一个网站,我想设计一个使用php:显示的文本样式
echo "Welcome: ".ucwords($name).". IP of our server is: ".ucwords($ip)." , and port is: ".ucwords($port)."<br>";
我想把整篇文章做成样式。我试着添加标签,例如
echo <div class="welcome_msg">"Welcome: ".ucwords($name).". IP of our server is: ".ucwords($ip)." , and port is: ".ucwords($port)."<br>"</div>;
它显示了一个错误:解析错误:语法错误,在第9行的C:''examplep''htdocs''index.php中出现意外的"/"
我该怎么修?
您还需要将<div class="welcome_msg">
和</div>
放在引号内。
像这样:
echo "<div class='welcome_msg'>Welcome: ".ucwords($name).". IP of our server is: ".ucwords($ip)." , and port is: ".ucwords($port)."<br></div>";
echo '<div class="welcome_msg">"Welcome: '.ucwords($name).'. IP of our server is: '.ucwords($ip).' , and port is: '.ucwords($port).'<br></div>';
**数字字(IP和端口)不需要ucwords
你也可以试试这个:
echo "<div class='welcome_msg'>Welcome: " . ucwords($name) . ". IP of our server is: " . ucwords($ip) . ", and port is: " . ucwords($port) . "<br></div>";
echo '<div class="welcome_msg"> Welcome: '.ucwords($name).'. IP of our server is: '.ucwords($ip).' , and port is: '.ucwords($port).'<br></div>';
您的HTML标记将被视为文本,并与其他文本一起用引号括起来。
因为HTML在文本中包含引号,所以需要通过在引号之前添加'
来转义文本中的引号。转义引号告诉PHP不要将特定的引号作为字符串的结束引号。
echo "<div class='"welcome_msg'">Welcome: ".ucwords($name).". IP of our server is: ".ucwords($ip)." , and port is: ".ucwords($port)."<br></div>";