PHP:使用变量实例化类 - $ new = new $ _GET ['class_name'];

I need to instantiate a class in PHP. I don't know what that class should be until I grab a $_GET['class_name'].

I want to do this:

$new_id = \App\Identification\ . $_GET['class_name']::find(1);

Instead I have to do:

if($_GET['class_name'] == 'Student'){
      $new_id = \App\Identification\Student::find(1);
}

I would really love any help!

You can try this way

$classNamespace = "\App\Identification\";
$class=$_GET['class_name'];
$path=$classNamespace. $class;
$new_id = $path::find(1);

Ok, here was my problem:

I was trying to concatenate the namespace with the variable my $_GET was returning.

Example:

$new_id = \App\Identification\ . $_GET['class_name']::find(1);

That won't work.
This will:

$full_path = '\App\Identification\' . $_GET['class_name'];
$new_id = $full_path::find(1);