# Initialize class with only the name of the class as a string

**URL:** <https://forum.kirupa.com/t/initialize-class-with-only-the-name-of-the-class-as-a-string/310143>\
**Category:** programming\
**Created:** [June 2, 2010, 5:23pm UTC](https://forum.kirupa.com/t/initialize-class-with-only-the-name-of-the-class-as-a-string/310143 "2010-06-02T17:23:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigepmest38](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sigepmest38](https://forum.kirupa.com/u/sigepmest38)\
**Post date:** [June 2, 2010, 5:23pm UTC](https://forum.kirupa.com/t/initialize-class-with-only-the-name-of-the-class-as-a-string/310143/1 "2010-06-02T17:23:36Z")

</div>

I am attempting to use an already initialized class in a function with only the string name of the class being passed to said function.

Example:

```php

class art{
  var $moduleInfo = "Hello World";
}

$art = new Art;

getModuleInfo("art");

function getModuleInfo($moduleName){
    //I know I need something to happen right here. I don't want to reinitialize the class since it has already been done. I would just like to make it accessible within this function.
    
    echo $moduleName->moduleInfo;
}

```

Thanks for the help!
