js字符串转化为布尔值_布尔值转换为字符串

js字符串转化为布尔值_布尔值转换为字符串

js字符串转化为布尔值

What happens when a false value is casted to a string?

false值强制转换为字符串会怎样?

I.e. what is the result of the following: < ?php var_dump((string)false); ?>

即以下结果是什么:<?php var_dump((string)false); ?>

The answer is: string(0) ""

答案是: string(0) ""

This is good to know and expect when using some string functions that sometimes return a string and sometimes a boolean. Such functions are strstr(), strpos(), etc.

当使用某些有时返回一个字符串,有时返回一个布尔值的字符串函数时,这是一个很好的认识和期望。 此类函数为strstr(),strpos()等。

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/booleans-casted-to-strings/

js字符串转化为布尔值