What are the characteristics of spaghetti code?

前端 未结 4 2234
囚心锁ツ
囚心锁ツ 2020-12-31 08:29

Somebody said that when your PHP code and application use global variables then it must be spaghetti code (I assume this). I use WordPress a lot. As far as I know, it\'s th

4条回答
  •  清歌不尽
    2020-12-31 08:46

    Well, talking of comment you posted, the explanation is very simple. Using global operator makes source of a variable is unknown, like other end of spaghetti noodle. It can be defined everywhere. So, when you call your function, you have no idea what value this variable has. Instead of it, direct passing a variable makes it plain and clear:

    function hello_testing($conditional_random) {
      if ($conditional_random)) {
          echo "foo is inside";  
      }
    }
    

    P.S. http://en.wikipedia.org/wiki/Spaghetti_code

提交回复
热议问题