Fragment 1 produced. Fragment 2 - no. Why?
1.
foo(); function foo() { // do soemething }
2.
foo(); if(!function_exists("foo")) { function foo() { // do soemething } }
See http://www.php.net/manual/en/functions.user-defined.php :
Functions do not have to be defined before they are referenced, unless the function is conditionally defined [...] Its definition must be processed earlier called.
You try to execute foo () before testing to make sure it is defined or not (and subsequently defines it)
if(!function_exists("foo")) { function foo() { // do soemething } } foo();
Source: https://habr.com/ru/post/1761484/More articles:Problem with autoload Html.DropDownList - asp.net-mvc-2Visual Style Visual Studio 2008 - c #Кодировка символов в строке - rubywhere is the join function? - stringC # Object Initialiser - reference to a new instance - syntaxsql query - sql-serverMy text is not html? - htmlPress enter key in qtp - vbscriptOpenCV: drawing an image - imageJUnit - website testing - javaAll Articles