Get the App
SLTechnology News&Howtos  ›  Development  › 

What's the difference between PHP5.5 and the previous version of empty function?

Shulou Source: shulou.com Published: 2022-06-03 14:57:18 10月01日 Update

This article mainly explains "what is the difference between PHP5.5 and the previous version of empty function". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between PHP5.5 and the previous version of empty function?"

The copy code is as follows:

If (strlen ($passwd) < 6 | | empty ($preg_replace ("/\ d /", ", $passwd) {

/ / do something

}

The general meaning is that the password must be greater than 6 digits and cannot be made up of only numbers. Search the server log and find the following error:

The copy code is as follows:

PHP Fatal error: Can't use function return value in write context in / xxx/xxx/xx.php on line xxx

Google a bit, which probably means that the argument to empty cannot be a function. Shit, the local area is obviously good. Take a look at the local PHP is 5.5, the server is 5.3. Does this function evolve between two versions? After searching all the PHP official documents, there was nothing to be found. Then google searched furiously and accidentally clicked to the PHP English document interface. Under the introduction of the empty function, a small print was found:

The copy code is as follows:

Note:

Prior to PHP 5.5, empty () only supports variables; anything else will result in a parse error. In other words, the following will not work: empty (trim ($name)). Instead, use trim ($name) = = false.

Summarize the usage scenarios of empty function:

Prior to 1.PHP 5.5, this function is used to check whether the assignment of a variable is 0, false, empty string, null. Any parameter in the form of a non-variable causes an error in this function.

2.PHP 5.5 this function can be applied to any value, not limited to variables. You can return values for constants, functions, and so on.

Thank you for your reading, the above is the "PHP5.5 and the previous version of the empty function is different" of the content, after the study of this article, I believe you have a deeper understanding of PHP5.5 and the previous version of the empty function has a deeper understanding of the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Function version code different variable learning content parameter that is document server service line between scenario official password small print constant form Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker OPPO Reno NVidia macOS Shulou Technology