You are not logged in.

#1 2016-01-15 09:42:00

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

[SOLVED] PHP: if __name__ == '__main__'

Hi,

The subject is a Python idiom, that much I know smile . JavaScript offers a similar hack, too:

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

Is there something like that for PHP? Examples of PHPUnit I've seen so far are conveniently restricted to testing classes. What is the right way with one file scripts in PHP? It's a fair scripting question, I presume.

Last edited by Llama (2016-01-15 15:19:04)

Offline

#2 2016-01-15 15:05:47

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: [SOLVED] PHP: if __name__ == '__main__'

Offline

#3 2016-01-15 15:18:26

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: [SOLVED] PHP: if __name__ == '__main__'

Thanks!

Looks like the real thing. Will take some time to grok, though smile .

Offline

Board footer

Powered by FluxBB