********更新**********
var_dump: string(0)
""
我试图检查数组的一部分是否为空,然后显示代码,但无论如何都显示代码.
我试过了!is_null !empty
.我不确定哪个应该是正确的,还是应该使用:
if (sizeof($book['Booking']['comments'])>0)
码:
<?php if (!empty($book['Booking']['comments'])) {?>
<table width="100%" border="0">
<tbody>
<tr>
<td style="font-family:'Lucida Grande', sans-serif;font-size:12px;font-weight:normal;color:#666666;">
<?=$book['Booking']['comments']?>
</td>
</tr>
</tbody>
</table>
<? } ?>
Run Code Online (Sandbox Code Playgroud)
阵:
Array
(
[Booking] => Array
(
[id] => 109
[user_id] => 1
[corporate_account_id] => 0
[id_ref] => RES000109
[price] => 178.00
[arrival] => 2011-10-18 00:00:00
[departure] => 2011-10-19 00:00:00
[rate_title] =>
[adult_guests] => 4
[child_guests] => 0
[company] => gravitate
[titlename] =>
[firstname] => John
[surname] => Doe
[address1] => 123 Fake St
[address2] =>
[city] => New York
[state] => NY
[postcode] => 12345
[country] => US
[phone] => 1111111111
[mobile] =>
[fax] =>
[email] => example@example.com
[comments] =>
[created] => 2011-10-18 13:40:47
[updated] => 2011-10-18 13:40:47
[status] => 1
[cancelled] => 0
[request_src] => website
[request_token] => 0
[token] => ayzrGnx
[survey_sent] => 0000-00-00 00:00:00
[survey_returned] => 0000-00-00 00:00:00
[send_sms] => 0
[payment_time] => 0000-00-00 00:00:00
[fullname] => John Doe
)
Run Code Online (Sandbox Code Playgroud)
我怀疑它可能包含(bool) FALSE
,但事实并非如此is_null()
.
试试简单:
if ($book['Booking']['comments']) {
Run Code Online (Sandbox Code Playgroud)
这也适用于任何评估的内容FALSE
,如空字符串.