Php IF语句新手
这导致我的网站崩溃,是否有明显的错误? 谢谢。Php IF语句新手,php,Php,这导致我的网站崩溃,是否有明显的错误? 谢谢。=是一项作业,您需要=进行比较 你也不应该有一个介于)和{之间这将起作用: <?php if ($user->getProfile()->get('title')="Canon"); { echo "Test1"; } else { echo "Test2"; }
=
是一项作业,您需要=
进行比较
你也不应该有一个代码>介于)
和{
之间这将起作用:
<?php
if ($user->getProfile()->get('title')="Canon"); {
echo "Test1"; }
else {
echo "Test2"; }
?>
首先,您需要一个比较'='',而不是一个赋值'='
然后,在条件之后出现了一个带有“;”的语法错误,您需要将=
符号更改为=
,因为第一个指定了一个值,而后一个对其进行比较
而且,您不需要用分号终止if
语句
<?php
if ( ($user->getProfile()->get('title')) == "Canon" ){
echo "Test1";
}
else {
echo "Test2";
}
?>
试试这个
if ($user->getProfile()->get('title') == "Canon") /* note that there is no semicolon here */
{ echo "Test1"; }
else
{ echo "Test2"; }
<?php
if ($user->getProfile()->get('title')=="Canon") {
echo "Test1";
}
else {
echo "Test2";
}
?>