Php 该职位已被删除
此帖子已被管理员或版主删除。如果您认为这是错误标记的,请联系客户支持以获取更多信息。您不必在一个回显中完成所有操作,代码缩进使阅读和调试更容易Php 该职位已被删除,php,mysql,Php,Mysql,此帖子已被管理员或版主删除。如果您认为这是错误标记的,请联系客户支持以获取更多信息。您不必在一个回显中完成所有操作,代码缩进使阅读和调试更容易 <?php if (!$UserLoggedIn) { echo "PLEASE LOGIN"; }else{ echo "<div style='background: #FFF;padding: 25px;box-shadow: 0 2px #bbb;margin: auto;positi
<?php
if (!$UserLoggedIn) {
echo "PLEASE LOGIN";
}else{
echo "<div style='background: #FFF;padding: 25px;box-shadow: 0 2px #bbb;margin: auto;position:relative;width: 600px;'>
<center>Welcome, {$GetLoggedUser->username}<br>
Here's some statistics about your account:<br>
Username: {$GetLoggedUser->username}<br>
Email: {$GetLoggedUser->email}<br>
UserID: {$GetLoggedUser->id}<br>
Banned from game: ";
if($GetLoggedUser->banned == "0") {
echo " no ";
} else {
echo " yes ";
}
echo "<br>Banned from website: {$GetLoggedUser->Ban} (obviously not or this page wouldn't show up)
<center/><div/>";
}
?>
您不必重复所有内容。。。不是我该怎么做的,但下面的示例中,您不能在回显字符串中执行If语句,但您可以执行三元操作,即(value==true)?“是”:“否”,但更容易脱离脚本并回显您需要的内容
<?
if (!$UserLoggedIn) {
echo "PLEASE LOGIN";
}else{
?>
<div style='background: #FFF;
padding: 25px;
box-shadow: 0 2px 2px #bbb;
margin: auto;
position:relative;
width: 600px;
'>
<center>
Welcome, <? echo $GetLoggedUser->username ?>
<br>
Here's some statistics about your account:
<br>
Username: <? echo $GetLoggedUser->username ?>
<br>
Email: <? echo $GetLoggedUser->email ?>
<br>
UserID: <? echo $GetLoggedUser->id ?>
<br>
Banned from game:
<? if($GetLoggedUser->banned == "0") { echo " no "; } else { echo " yes "; } ?>
<br>
Banned from website: <? echo $GetLoggedUser->Ban ?> (obviously not or this page wouldn't show up)
<center/>
<div/>
<? } ?>
欢迎
以下是有关您帐户的一些统计信息:
用户名:
电邮:
用户标识:
禁止参加游戏:
禁止进入网站:(显然不是,否则该页面不会显示)
您仍然可以尝试:
禁止参加游戏:
if($GetLoggedUser->banned ==
"0") { echo " no "; } elseif ($GetLoggedUser->banned == "1") { echo "
yes "; }
为了显示更多的HTML
,我更喜欢通过关闭和重新打开PHP
标记在PHP
和HTML
之间切换
我正在使用echo
(
)的简短语法将PHP
中的值插入HTML
<?php
if (!$UserLoggedIn) {
echo "PLEASE LOGIN";
} else {
?>
<div style='
background: #FFF;
padding: 25px;
box-shadow: 0 2px 2px #bbb;
margin: auto;
position:relative;
width: 600px;
'>
<center>
Welcome, <?= $GetLoggedUser->username ?>
<br>
Here's some statistics about your account:
<br>
Username: <?= $GetLoggedUser->username ?>
<br>
Email: <?= $GetLoggedUser->email ?>
<br>
UserID: <?= $GetLoggedUser->id ?>
<br>
Banned from game: <?= $GetLoggedUser->banned == '0' ? ' no ' : ' yes ' ?>
<br>
Banned from website: <?= $GetLoggedUser->Ban ?> (obviously not or this page wouldn't show up)
</center>
</div>
<?php
}
当PHP
中封装HTML
时,一些ide无法解释它,因此当您仅使用echo输出HTML
时,它们无法帮助语法突出显示
<?php
if (!$UserLoggedIn) {
echo "PLEASE LOGIN";
} else {
?>
<div style='
background: #FFF;
padding: 25px;
box-shadow: 0 2px 2px #bbb;
margin: auto;
position:relative;
width: 600px;
'>
<center>
Welcome, <?= $GetLoggedUser->username ?>
<br>
Here's some statistics about your account:
<br>
Username: <?= $GetLoggedUser->username ?>
<br>
Email: <?= $GetLoggedUser->email ?>
<br>
UserID: <?= $GetLoggedUser->id ?>
<br>
Banned from game: <?= $GetLoggedUser->banned == '0' ? ' no ' : ' yes ' ?>
<br>
Banned from website: <?= $GetLoggedUser->Ban ?> (obviously not or this page wouldn't show up)
</center>
</div>
<?php
}
欢迎
以下是有关您帐户的一些统计信息:
用户名:
电邮:
用户标识:
禁止参加游戏:
禁止进入网站:(显然不是,否则该页面不会显示)
什么?他在一根回音弦里面,这纯粹是胡说八道!分析错误:语法错误,意外的“if”(T_if),应为“,”或“;”很抱歉第二次回音后忘记了一个:
。固定现在不要依赖于在任何地方工作。它们已经过时,不推荐使用,不太可能在配置良好的服务器上工作。不要依赖于在任何地方工作。它们已经过时,不推荐使用,不太可能在配置良好的服务器上工作。