0

Dynamic languages tend to have features which allow for checking the way of using a module. Otherwise it would have been hard to unit test functions of the main script, for instance.

Python:

if __name__ == '__main__':
    my_main()

JavaScript:

if(require.main === module) {
  myMain();
}

Is there a way to do something like this in PHP? Sorry, it's a very newbie question, but I lack the right keywords, apparently.

Alexey Orlov
  • 2,412
  • 3
  • 27
  • 46

0 Answers0