Whats wrong with my if else statement

前端 未结 1 1886
半阙折子戏
半阙折子戏 2020-12-12 06:07

I have a $name variable containing a string, and when I test it, I never get the \"Name should be between 2 and 40 characters\" error even when it\'s less than

1条回答
  •  盖世英雄少女心
    2020-12-12 06:54

    How can the length be less than 2 and greater than 40? You want || ("or"), not && ("and").

    if (strlen($name) < 2 || strlen($name) > 40) {
    // -------------------^^
    

    0 讨论(0)
提交回复
热议问题