Best practices in web development: use of empty

The empty() function in PHP is used to check if a variable exists and if its value is considered empty. It is a good practice to make your code not to break when you receive variable values that you have to secure It returns true if the variable does not exist or if its value is one of the following: As empty checks that the variable exists, it would save us this statement: To this one which is much more abbreviated: For an array we should also add the check if it is an array: And you could also use it in a ternary: But in these cases, […].

Logo David
Privacy Resume

Esta web utiliza cookies para que podamos ofrecerte la mejor experiencia de usuario posible. La información de las cookies se almacena en tu navegador y realiza funciones tales como reconocerte cuando vuelves a nuestra web o ayudar a nuestro equipo a comprender qué secciones de la web encuentras más interesantes y útiles.Para más información consulta nuestra <a href="/politica-privacidad/">Política de Privacidad</a>