CS174
Chris Pollett
Apr 7, 2021
if (file_exists(__DIR__."/../../vendor/autoload.php")) { require_once __DIR__."/../../vendor/autoload.php"; } else { spl_autoload_register(function ($class) { // project-specific namespace prefix $prefix = 'seekquarry\\yioop\\tests'; // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { $prefix = 'seekquarry\\yioop'; $len = strlen($prefix); // no, move to the next registered autoloader if (strncmp($prefix, $class, $len) !== 0) { return; } else { $check_dirs = [WORK_DIRECTORY . "/app", BASE_DIR]; } } else { $check_dirs = [PARENT_DIR . "/tests"]; } // get the relative class name $relative_class = substr($class, $len); // use forward-slashes, add ./php $unixify_class_name = "/".str_replace('\\', '/', $relative_class) . '.php'; foreach($check_dirs as $dir) { $file = $dir . $unixify_class_name; if (file_exists($file)) { require $file; break; } } }); }
use some_company\some_project\IntHolder ;Then create an instance of IntHolder using the line and echo $my_num:
$int_holder = new IntHolder(6); echo $int_holder->my_num ."\n";