Advance Practical PHP | Namespace - video #29

Поделиться
HTML-код
  • Опубликовано: 8 окт 2024
  • We are talking about the namespace that solve two different problems. The ‘Namespaces’ are qualifiers that allows for better organization by grouping classes that work together to perform a task. They allow the same name to be used for more than one classes.
    A “namespace” can contain valid PHP code. Namespace affects the following types of code like “classes (including abstracts and traits)”, “interfaces,” “functions”, and “constants”. Namespaces are declared using the “namespace” keyword. Put it at the top of your script.

Комментарии • 2

  • @JacquelineRomero-q1h
    @JacquelineRomero-q1h 12 дней назад +1

    hey, do you really need to use namespace? I find it difficult to use.

    • @JacquelineRomero-q1h
      @JacquelineRomero-q1h 12 дней назад +2

      In the broadest definition namespaces are a way of encapsulating items. This can be seen as an abstract concept and it is but it is a good idea to use them because you might be working on a big project with others and this tech is a way of you avoiding cross contamination. Meaning, your variable will not cross with others especially if they are using the same naming convention as yours.