Doubt about declaring a class with if (! class_exists) in PHP

1

I would like some help to better understand the logic of this situation below.

A parent file makes an include of another file that contains only one class .

/main-file.php:

require_once('/other-file.php');
new ExampleNameClass( 'arg1', basename( 'arg2' ) );

/other-file.php:

if( !class_exists('ExampleNameClass') ) {
  class ExampleNameClass {
  [...]

As far as I understand, the file that declares the class will only get into the condition if the NO class does not exist (!class_exists)... . But it does not really exist , so I found this condition unnecessary.

Could someone clarify why the person did it this way? Is there anything related to security?

    
asked by anonymous 16.07.2018 / 02:27

0 answers