我目前交給一個由不同公司主持的php項目。我的核心領域是Java,所以與PHP相關的一切都是新的。當我運行該項目時,很難知道瀏覽器顯示哪個PHP文件因爲URL沒有顯示實際的PHP文件名,因爲'URL重寫'。我嘗試刪除URL重寫規則表單.htaccess文件,但之後應用程序停止工作,因爲我做了圓頂錯誤。爲了獲得項目流,我只需要了解瀏覽器當前顯示哪個文件。請幫助我實現此目的。如何知道我在哪個php頁面?
1
A
回答
0
您可以使用基名()和$ _ SERVER [「PHP_SELF」]獲得當前頁面的文件名
echo basename($_SERVER['PHP_SELF']); /* It's returns The Current PHP File Name */
0
他們多少重寫在.htaccess文件? 他們中的每一個都應該引導你到一個特定的文件,那就是你正在尋找的文件。
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__;
相關問題
- 1. 我如何知道這個頁面打哪個控制器?
- 2. 我如何知道哪個php頁面請求當前的php腳本?
- 3. 視圖如何知道ajax MVC WebGrid在哪個頁面上?
- 4. 如何知道哪個頁面被重定向?在javascript
- 5. 如何知道在登錄JSF 2頁面之前請求了哪個頁面
- 6. 我如何知道正在使用哪個桌面環境?
- 7. 讓jquery知道哪個是最後訪問過的php頁面?
- 8. 如何知道我需要哪個RedirectToAction?
- 9. 如何知道用戶點擊了Gtk.Notebook中的哪個頁面?
- 10. 如何知道從哪個jsp頁面調用servlet
- 11. 如何知道哪個按鈕回傳頁面?
- 12. 應用程序如何知道從哪個頁面訪問它?
- 13. 如何知道PDF規範中圖像屬於哪個頁面?
- 14. 如何知道哪個頁面觸發了Session Start事件?
- 15. 如何知道從MasterPage中調用哪個子內容頁面
- 16. Android,如何知道ViewPager的哪個頁面已被點擊?
- 17. 如何知道一個頁面在unix中變成髒頁面
- 18. PHP - 我如何知道它當前的頁面名稱?
- 19. 我知道如何在LAMP堆棧上構建HTML5/PHP頁面,不知道如何在Windows IIS中啓動
- 20. 我可以知道哪些頁面在_Layout中渲染?
- 21. 如何知道我們來到一個頁面從另一個頁面
- 22. 如何知道誰在頁面上?
- 23. 不知道如何處理一個純粹的PHP頁面
- 24. Unity3D網頁播放器:如何知道我在哪裏加載
- 25. Vim和php:我怎麼知道我在哪個函數?
- 26. 如何知道用戶從哪個URL重定向到我們網站的一個頁面php
- 27. 知道用戶在iframe中瀏覽哪個頁面
- 28. Python:我如何知道我正在導入哪個包?
- 29. 我如何知道我在git中檢出了哪個版本?
- 30. 我如何知道我正在運行哪個WPF版本?
這是我的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
看來index.php文件是用來管理所有不同的包含。 可能有一個代碼片段管理不同的包含。這就是你應該回顯包含文件名稱的地方。 –
這裏不可能顯示jsp的索引內容請幫助我如何向你發送文件內容 – JG1991