[resolved] open file at cursor |
Site Admin
|
and your path becomes D:libsfile.php which is what PhpED can't open. Either use / or double slashes like below: require_once 'D:/libs/file.php'; require_once 'D:\\libs\\file.php'; |
||||||||||||||
_________________ The PHP IDE team |
Veteran
|
In PHP, one needs to use double quoted stings when escaping characters. In other words, the following variations are valid:
and these are not valid
I think it would be more intuitive if PhpED followed PHP's example |
||||||||||||||||
|
require file |
|
Howdy,
I am trying to require a file from the same directory as the opened file that I am in, <?php require_once('noname1.php'); ?> The file the above code is in is: /root/test/1/noname2.php But the file the Open File at Cursor opens is, /root/noname1.php It pulls from the root directory. Jeff |
||||||||||||
|
Site Admin
|
Why do you believe that this call will include noname1.php from current directory? It's just a wrong assumption Say you have A.php in the root directory and this file includes B.php that is in "lib" subrirectory. If B.php includes C.php and does so without path, php will look for C in the root because it's where A is. Please read PHP rules for included files. |
||||||||||||||
_________________ The PHP IDE team |
|
I dont know what the rules of php are saying on this matter, but I do know that php has always and still calls to the the most relative file. If the calling file is in the same directory as the required file, then unless an absolute path is specified, it looks for the file within the immediate directory of the calling file. Now if the rules of php specify something different then this, then they do not reflect the way php works. When I run noname2.php on the linux server, it calls to noname1.php which is located in the immediate directory and not to the one located in the root. Now it is the same for other scripts too. Consider this: I create two directories located in /root /root/1/ - 1_1.php /root/2/ - 1_1.php - 1_2.php In 1_2.php from /root/2/ I add the line: require_once('1_1.php'); then i right click to open at cursor But phped doesnt open 1_1.php located in the directory /root/2/ even though that is where the calling file is located and the target file. Instead it opens the file (1_1.php) from the directory (1/) But run this same example on the server and php will open the file 1_1.php as it is located in the directory /root/2/ i.e., the same directory where the calling file is located. Jeff |
||||||||||||||||
|
|
I think the rules Dmitri is referring to is the PHP include search rules. By default, PHP will search in the current working directory (I think the directory where script started in) then in the include directories. But, you can change the working directory by using chdir() in you PHP script. So, assuming where an include is located may not work. Cameron. |
||||||||||||||
|
Site Admin
|
Right, I referred to php rules that php uses for include/require statements:
As a bottom line, from the IDE perspectives, it does not know "current directory". Say we're in B.php that includes C.php. But B.php itself is included from A.php and what you call in your url is A.php. Current directory will be A's directory. But B.php does not know it and what relative path you use in the include statement in B.php, will be appended to A's path. Subsequently if you include B.php in A2.php, it will use A2's path... Needless to say that IDE does not know what files you will run as the 1st level files and therefore it does not know how to use relative path it sees in the include(). That's why we added INCLUDE tab in the project properties. Please make sure you have all include() statements properly resolved there. |
||||||||||||||
_________________ The PHP IDE team |
|
Dmitri, are you saying that phped is not able to find the file even though php is able to find it? I mean is it your intention that phped look for files differently than php, because im my example that I posted, that is clearly what it is doing. Jeff |
||||||||||||||||
|
Site Admin
|
Jeff,
No PHP IDE in the world know the path that php will use. IDE can only guess the path. There are cases when guessed path matches real life, and there are always cases when can not guess. PhpED is just an instance of the IDE and therefore conforms the rule above. You may help it by providing correct path on the INCLUDES tab as I said before. You're wrong assuming that the relaive path you use in include() is realative from the current file location. It's only the case with files that you call with URL. For the other files, that may not work. It's a weak side of php engine as it was created in the beginning. |
||||||||||||
_________________ The PHP IDE team |
|
All I know is that Dreamweaver's implementation of open file at cursor gets it right so far every time where as phped doesnt. So apparently it is possible for an editor to get it right which is all that matters, unless of course you have some case studies that demonstrate that dreamweaver doesnt get it right. My point is exactly that phped should get it right and can but doesnt. I even used the refresh option provided in the includes section for the project, and it still doesnt get it right. If I have to manually fix each include, then that is counter productive. I can just use dreamweaver to find the file which is far more sensible then manually fixing every include path.
If that is the case then why does php on my server always, not sometimes, call to the immediate file relative to the current location rather than some file located elsewhere? Perhaps I am misunderstanding you but I did some tests and php always grabs the file closest to the calling file except in the instance where you chain the files like in your example, which isnt the case here. Jeff |
||||||||||||||||
|
Site Admin
|
seems this discussion is more about theory than practice. Let's consider the followin simple example. I suppose you know php quite well so you'll guess what path will be printed.
create a.php in the root directory of disc C:\ with the following content:
create directory include in c:\ and create file b.php in it (its full path will be c:\include\b.php) and its content should be:
create one include subdirectory within include and file c.php in it (its full will be c:\include\include\c.php) and its content should be:
create a copy of c.php one level upper then try to run a.php with any php engine you have. |
||||||||||||||||||
_________________ The PHP IDE team |
[resolved] open file at cursor |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by