The advantage / disadvantage between global variables and function parameters in PHP?

后端 未结 6 2043
生来不讨喜
生来不讨喜 2020-11-27 07:00

sorry i\'m a beginner and i can\'t determine how good a question this is, maybe it sounds utterly obvious to some of you.

if our use of these two below is t

6条回答
  •  天涯浪人
    2020-11-27 07:46

    Pass in parameters, avoid globals. Keeping only the scope you need for a given situation is a measure of good code design. You may want to look at PHP variable scope...

    http://php.net/manual/en/language.variables.scope.php

    An excellent resource, with some pointers on what is best practices and memory management.

提交回复
热议问题