if the directory i need to use dirname() is…
- User
if the directory i need to use dirname() is "/home/user444/domains/website.com/public_html" i need to get home so would that be dirname(DIR, 4)
- Assistant
Yes, you're on the right track. The
dirname()function in PHP can be used to get a parent directory by specifying the number of levels you want to go up. If you have the directory path"/home/user444/domains/website.com/public_html", and you want to get/home, which is four levels up frompublic_html, you would indeed usedirname(__DIR__, 4).Here's a breakdown of how this works:
- Level 1:
/home/user444/domains/website.com/public_html->/home/user444/domains/website.com - Level 2:
/home/user444/domains/website.com->/home/user444/domains - Level 3:
/home/user444/domains->/home/user444 - Level 4:
/home/user444->/home
So,
dirname(__DIR__, 4)would give you/home. Just make sure that__DIR__resolves to/home/user444/domains/website.com/public_htmlwhen the code is executed. - Level 1:
- User
i cant seem to get yii2 to work on this new webhost... its pissing me off
- Assistant
- User
i dont even think im getting past the index.php file.. the structure is weird with hostinger
- Assistant
- User
hostinger has a strange directory structure "/home/user933/domains/website-name.com/public_html/" so when doing the entry script require.. i dont think im accessing autoload and yii
- Assistant