문제

I want to only check for length of this value if the variable is not empty and ignore checking length if the variable is empty. The following Always checks length and doesn't consider the first parameter of the if statement.

PHP

if ($Zip !== '' && (strlen($Zip) !== 4)){
도움이 되었습니까?

해결책

Try this:

if (!empty($Zip) && (strlen($Zip) !== 4)){

Apply this code and remove your code. It will work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top