0

I have PHP application, that runs about 2-3 minutes before it return something to browser (some database processing stuff).

I want to know, if I can change php file with it while script is running. I assume, there is a buffer in Apache/PHP.

I have situation like this:

// This is index.php

include "DatabaseController.php"; // class inside, I create instance at start
include "ImagesController.php";  // class inside, I create instance at start
include "helpers.php"; // there are just functions, no classes

$db = new Database();
$img = new Images();

// for loop doing job here (2-3 minutes)

// end

What will happen, when I replace "DatabaseController.php" file while script is running?

I tried to test it, and it looks like "job part" is still using old version of DatabaseController, when I replace.

But... what will happen, when I replace "helpers.php" file? It contains only functions, without classes that may be instantiated at the beginning of script.

How this buffering works in general?

6
  • Nothing will happen if you change the file while its in executing... Commented Aug 1, 2013 at 23:18
  • You mean, that all included files are buffered too? Commented Aug 1, 2013 at 23:19
  • 1
    If they're included already, their behavior won't change (changed to opcode). If your script starts, then you change the file, and only then the include happens, it will of course see the new file. Commented Aug 1, 2013 at 23:21
  • Yes, because included files are part of the main file, everything will be loaded and then executed, therefore, once the request sent, and the files being included, changes not affect them at all... Commented Aug 1, 2013 at 23:22
  • @Wrikken: the time is very very very small, that I can say its zero for manual changing Commented Aug 1, 2013 at 23:23

1 Answer 1

1

Its not really being buffered. You should read up on Compilers. In summary, the code you write will first need to be compiled before it can be executed. Changes you make to the source after it has been compiled will not take effect until the next request when it will be recompiled again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.