How to solve the problem?

Formulation:
Using constants and serving their function, achieve the design require the behaviour of require_once. In other words, at repeated inclusion of PHP file, for example, the Point class, the code in the include file needs to be executed once.
I can not understand correctly decided.
<?php
//class_point.php 
class Point
{
 public $x;
 public $y;

 const ClassName = __CLASS__;
}

<?php
//index.php
define('CLASS_POINT', require('class_point.php'));

if (defined('CLASS_POINT')) {
 if (CLASS_POINT) {
 echo "File already connected\n";
}
}

$obj = new Point();
echo $obj->x = 1;
echo "\n";
echo $obj->y = 2;
echo "\n";
March 23rd 20 at 19:13
2 answers
March 23rd 20 at 19:15
Solution
Any way prevent the announcement. Check the presence of constants, if there is, do nothing.

if (!defined("CLASS_POINT_DEFINED")) {
 define("CLASS_POINT_DEFINED", "CLASS_POINT_DEFINED");

 class Point {

}
}
March 23rd 20 at 19:17
class to wrap in an if, but it's some kind of freak by the letter m..

Find more questions by tags PHP