DudeOnRock
DudeOnRock

Reputation: 3831

Get directory of class definition in php

I know about dirname(__FILE__), which returns the directory of the script that calls the function. Is there a way to get the directory of where the class that is returned with get_called_class() is defined?

Upvotes: 0

Views: 108

Answers (1)

nice ass
nice ass

Reputation: 16709

Use ReflectionClass:

$reflector = new ReflectionClass(get_called_class());
print dirname($reflector->getFileName()));

(this won't work for internal classes :)

Upvotes: 1

Related Questions