对此可能有一个非常简单的解决方法,但我对 php 很陌生,而且非常无知。我一直试图解决这个问题,但无济于事。这是代码:
echo $slot['slot_type'];
echo "<br><br>";
if ($slot['slot_type']='tree') echo "This place is full of life, and can be used for hunting, gathering, logging, or other activities.";
if ($slot['slot_type']='town_hall') echo "The town hall houses the governors, and is propriety of the King.";
if ($slot['slot_type']='farm1') echo "Townspeople attempt to grow a selection of wild plants on these crops, hoping for a steady food supply.";
if ($slot['slot_type']='farm2') echo "Farming is hard work, but a full storehouse of food is a great comfort.";
第一行echo $slot['slot_type'];
是我试图理解为什么我的“if”语句不起作用的尝试。但是,它会打印正确的字符串,在本例中为“tree”。
因此,在实践中,浏览器不会打印建议的文本字符串之一,而是打印所有四个字符串,就好像它完全忽略了我的 IF 语句一样。再次,很抱歉问了一个看起来如此愚蠢的问题。