pranshu82202 Posted August 20, 2011 Share Posted August 20, 2011 I am very confused in between these three terms INCLUDE, REQUIRE, HEADER... Can anyone tell me the difference between these three terms... I just want to run a php file in the if condition.. Basically i do not want to open i just want to run ... for ex. <?php if(condition) { // run mail.php file } ?> Quote Link to comment https://forums.phpfreaks.com/topic/245295-include-require-header/ Share on other sites More sharing options...
OneShot Posted August 20, 2011 Share Posted August 20, 2011 Header will forward the user to a specified page somewhat like an HTML meta redirection. include will include whatever page and run it's code in that page, so basically if would be the same as if you copied the code from the included page and pasted it in the page asking to include that page. require is the same exact thing as include with the exception that any error will result in a fatal error while include will shoot an error but continue. From php.net: The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well. Be warned that parse error in required file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does. Quote Link to comment https://forums.phpfreaks.com/topic/245295-include-require-header/#findComment-1259902 Share on other sites More sharing options...
trq Posted August 21, 2011 Share Posted August 21, 2011 Header will forward the user to a specified page somewhat like an HTML meta redirection. This statement is all together incorrect. The header function sends http headers back to the client. One of the common headers sent happens to be the Location header which asks a browser to redirect to another location. Quote Link to comment https://forums.phpfreaks.com/topic/245295-include-require-header/#findComment-1260000 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.