The content of a file can be inserted into a PHP file before the server executes it, with the include() or require() function. The PHP way of including a file is not always straightforward and requires clear understanding of include_path directive. Basically if you are using a relative path name, PHP will search for the file using the directories in the PHP include path. Finding files included in PHP File and understanding of the mappings between fie paths in include() and corresponding absolute file path on the disk are much easier with PhpED's Open File at Cursor feature and PhpED's Project Properties Includes tab.
How to open PHP File listed in include() or require() functions of PHP.
Open PHP file at the cursor feature literally puts your PHP and/or other files at your fingertips. Just click the right mouse button when the cursor is over the name of the file and select "Open File at Cursor". For example, the illustration below shows "Open File at Cursor" at work in index.php PHP File when the user is placing cursor over header.php includion.
|
|
|
How to see the path in PHP include() or require() functions resolved on the server.
Virtually every PHP file will have one or more include() or similar function calls creating the hierarchy of included files. The situation will get more complex when an included PHP File also has a nested file or files included in it. To make the life of PHP designer easier, PhpED provides the Includes tab on the Project Properties dialog. When the project is created, PhpED resolves all include and require calls and displays the resulting file mapings in the tab.
|
|
|
To view the includes structure for your PHP files or file you can:
- Create a Project in PhpED
- Select project->Project Properties>Includes tab
- Select Refresh button to make sure that your Project File data is parsed
The three columns of Incudes tab are:
- Source File - displays the location of the PHP File with an include statement with respect to the Project or Web Root
- Include statement - displays the actual function call resulting in inclusion of PHP file
- Resolved File name - shows what this Include statement is resolved to and the actual path to included PHP file.
In this tutorial you learned how to take advantage of PhpED features for simplifying working with PHP File include statements and other common PHP file editing operations..Additional technical information is available from the NuSphere Forum. Download a free trial of our PHP IDE today!
|