In PHP, 0 (int, zero) is equal to “first” or “last” (strings)?

前端 未结 4 734
猫巷女王i
猫巷女王i 2021-01-21 07:43

I\'m confused by something I just ran into in a script I was working on. I had the following:

function getPart($part)
{
    $array = array(\'a\', \'b\', \'c\');         


        
4条回答
  •  梦毁少年i
    2021-01-21 08:04

    Check out (int) 'first'. That is essentially what PHP is doing to the right hand operand.

    PHP will coerce operand types when not using the strict equality comparison operator (===) between two operands of different types.

提交回复
热议问题