urosh Posted January 5, 2007 Share Posted January 5, 2007 Hi all, i am new with PHP, and i would like to know if it is possible to use one file by two different functions at the same time. That is, one function will read information from the top of the file, while second function will add information on the bottom of the file. Second function is much faster in its job so ther is no problem that first function will come to the end of the file before second function finish its work. Is this possible, or i need to break the file into more files that will be approached by only one function at the time?Thanks in advanceUrosh Quote Link to comment https://forums.phpfreaks.com/topic/32946-handling-files/ Share on other sites More sharing options...
urosh Posted January 5, 2007 Author Share Posted January 5, 2007 Litle clarification. Actually these two functions are two executables. First executable put some information into the file, while second one reads information from the file, and do some work. As second executable is much slower, idea is to try to save some time, by getting available information as soon as it is available. If anyone have an idea if that is possible? Quote Link to comment https://forums.phpfreaks.com/topic/32946-handling-files/#findComment-153501 Share on other sites More sharing options...
Daniel0 Posted January 5, 2007 Share Posted January 5, 2007 If I understood you correctly, then you're trying to run two functions at the same time. That is not possible. Quote Link to comment https://forums.phpfreaks.com/topic/32946-handling-files/#findComment-153855 Share on other sites More sharing options...
urosh Posted January 6, 2007 Author Share Posted January 6, 2007 I am trying to run two executables at the same time, by forking processes it should be possible? Andif it is possible, i want them to use the same file at the same time, that is one to read from the file, one to write to the file. Quote Link to comment https://forums.phpfreaks.com/topic/32946-handling-files/#findComment-154226 Share on other sites More sharing options...
utexas_pjm Posted January 6, 2007 Share Posted January 6, 2007 What you're asking can be done with PHP in a *nix environment outside of a webserver. A quick google search yielded this site: http://www.electrictoolbox.com/article/php/process-forking/ which might be of help to you. Honestly though, PHP probably isn't the best solution I think you'd be better off with a language that supports threading i.e., Java.Best,Patrick Quote Link to comment https://forums.phpfreaks.com/topic/32946-handling-files/#findComment-154317 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.