BasePath & Url

Are there any methods that resolve to the base path? like where index.php is located. I looked at the reference and saw only something like


that resolves to the protected directory.


that will return with the index.php in it. How about just the full path the index.php located in but without the actual file name. just the path? (I know i can do this easily with just removing index.php just want to make sure if anything else exists to avoid hard-coding stuff)


Do you mean


maybe basename(…) ?

@notzippy no this returns an error because i need to define the baseurl and i was talking about the basepath

@Bethrezen Nope that will return the filename for the $dir variable entered

So I am assuming you want the parent directory of the protected folder ?:


Yes exacly that code. The question was if there was a method that does that?

Nope. Use dirname(Yii::app()->request->scriptFile).

thans for your comment .

it works for attaching images from the /images folder that is availavle in parent directory of protected .