# Simple function that returns class name as a string?

**URL:** <https://forum.kirupa.com/t/simple-function-that-returns-class-name-as-a-string/331957>\
**Category:** flash\
**Created:** [December 6, 2013, 7:20pm UTC](https://forum.kirupa.com/t/simple-function-that-returns-class-name-as-a-string/331957 "2013-12-06T19:20:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [December 6, 2013, 7:20pm UTC](https://forum.kirupa.com/t/simple-function-that-returns-class-name-as-a-string/331957/1 "2013-12-06T19:20:34Z")

</div>

Is there a way to formulate a function within a custom class, say MyClass, that returns the string “MyClass”?

In other words:

```php

package {
      public class MyClass { 
         public function MyClass() {
               . . . 
              trace(className()); // MyClass
          }
           private function className():String {
                var str:String;
                // do something
                return str;
           }
      }
}

```
