2015-09-21 33 views
1

我目前交給一個由不同公司主持的php項目。我的核心領域是Java,所以與PHP相關的一切都是新的。當我運行該項目時,很難知道瀏覽器顯示哪個PHP文件因爲URL沒有顯示實際的PHP文件名,因爲'URL重寫'。我嘗試刪除URL重寫規則表單.htaccess文件,但之後應用程序停止工作,因爲我做了圓頂錯誤。爲了獲得項目流,我只需要了解瀏覽器當前顯示哪個文件。請幫助我實現此目的。如何知道我在哪個php頁面?

回答

0

您可以使用基名()和$ _ SERVER [「PHP_SELF」]獲得當前頁面的文件名

echo basename($_SERVER['PHP_SELF']); /* It's returns The Current PHP File Name */ 
0

他們多少重寫在.htaccess文件? 他們中的每一個都應該引導你到一個特定的文件,那就是你正在尋找的文件。

+0

這是我的htaccess文件'SETENV magic_quotes的0 SETENV PHP_VER 5 選項+了FollowSymLinks -MultiViews RewriteEngine敘述在 的DirectoryIndex的index.php 的RewriteCond%{REQUEST_URI} ^系統。* 重寫規則(。*) ?!的index.php/$ 1 [L] 的RewriteCond%{REQUEST_FILENAME} -f 的RewriteCond%{REQUEST_FILENAME} -d 1 的RewriteCond $ ^(指數\ .PHP |圖像|機器人\ .TXT | CSS)! 重寫規則( 。*)index.php?/ $ 1 [L] order allow,denny al低從所有 拒絕someurl'如果你能幫我編輯這個我會完成。 – JG1991

+0

看來index.php文件是用來管理所有不同的包含。 可能有一個代碼片段管理不同的包含。這就是你應該回顯包含文件名稱的地方。 –

+0

這裏不可能顯示jsp的索引內容請幫助我如何向你發送文件內容 – JG1991

1
echo __FILE__;  
$included = get_included_files(); 
var_dump($included); 
1

用途:

<?php echo $_SERVER['SCRIPT_NAME']; ?> 

或使用可以使用print_r($_SERVER)你想知道有關文件和服務器什麼都

0

PHP有魔術常量保存其文件的所需資料:http://php.net/manual/en/language.constants.predefined.php

__LINE__  The current line number of the file. 
__FILE__  The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned. 
__DIR__  The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. 
__FUNCTION__ The function name. 
__CLASS__  The class name. The class name includes the namespace it was declared in (e.g. Foo\Bar). Note that as of PHP 5.4 __CLASS__ works also in traits. When used in a trait method, __CLASS__ is the name of the class the trait is used in. 
__TRAIT__  The trait name. The trait name includes the namespace it was declared in (e.g. Foo\Bar). 
__METHOD__  The class method name. 
__NAMESPACE__ The name of the current namespace. 

就這樣使用它:

echo __DIR__; 
相關問題