在视图中加载视图,如何获取主视图的名称?

I have created a view main.php and I have loaded the view internal.php inside main.php

Now, using the following code inside internal.php:

pathinfo(__FILE__, PATHINFO_FILENAME), '.php'

or the code:

echo $_ci_view;

i am getting internal.php while I want main.php as it is the main view being loaded in browser window. How can I do this?

you can parse the url like this:

$q=parse_url($_SERVER['REQUEST_URI']);
$q=(isset($q['path']))?$q['path']:''; 

echo $q outputs e.g.: '/main.php'

see more at the php manual and about parse_url()

use include 'location/filename.php'; inside main.php

ref https://www.w3schools.com/php/showphp.asp?filename=demo_include2