In PHP, we have:
<?php include 'external_file.php'; ?>
Whereas in Java, you have imports:
import javax.servlet.http.HttpServlet;
It is to my understanding that PHP includes simply dump the contents of the external file into the file that contains the include statement.
My gut feeling is that Java handles these includes/imports differently than PHP. What are the key differences?
PHP's include is pretty much the exact same thing as having literally cut/pasted the raw contents of the included file at the point where the include() directive is.
Java's compiled, so there's no source code to "include" - the JVM is simply loading object/class definitions and making them available for use. It's much like the #include directives in C. you're not loading literal source code, just function definitions/prototypes/fingerprints for later use.
In php it simply dumps the contents of the file in the current file. In Java, an imported class is used:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With