I am confused with two terms
header ("Location:homepage_php");
include("homepage.php");
I am guessing that header is used after checking password procedure and about include, you can use it anywhere. But i am not sure what is actual difference between them and at what place out of these two one should be used.
The header function is used to send raw HTTP headers back to the client: PHP header function
<?php
header("HTTP/1.0 404 Not Found");
?>
The above (taken from the PHP documentation) sends a 404 header back to the client.
The include function is used to include files into the current PHP script (the same as require) PHP include function
vars.php
<?php
$color = 'green';
$fruit = 'apple';
?>
test.php
<?php
echo "A $color $fruit"; // A
include 'vars.php';
echo "A $color $fruit"; // A green apple
?>
This example (again from the PHP documentation) includes the vars.php script in the test.php script and, after the include, allows the test.php script to access the variables declared in the vars.php script.
Header forwards the user to a new page, so PHP reinitializes, it's like a HTML meta redirection, but faster.
Include just includes the file where you call it, and it executes it as PHP, just like if the code from homepage.php was written where you write <?php include('homepage.php'); ?>
.
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