Can someone give me a good reason why a statement in php behaves the way it does?

The assertion of a PHP statement does not behave like most other languages.

assert ('return false'); actually evaluates the string and then claims its result (false).

Instead of comparing the parameter with the true one, it goes through an additional step of checking the argument and, if it evaluates it, then performs the comparison.

Very strange.

My problem is not understanding behavior, my problem arises with a good reason for this behavior, especially. since now you need to do additional mental work of thinking ... "does it evaluate the string?".

thanks

+3
source share
2

, , , . , , , , , assert_options(), , boolean FALSE .

http://www.php.net/manual/en/function.assert.php

+11

, , . , PHP, , . , "" , ( : -P).

EDIT: . Jakob PHP .

+1

Source: https://habr.com/ru/post/1704795/


All Articles