I am a programmer and I am picking up PHP, I cannot seem to search for this so I hope this is not a duplicate. Currently this is giving me an error at line 4 on header.php which says:
unexpected $end
I know that it is complaining about the syntax but I don’t fully understand how the files are parsed processed and get executed at runtime (hence creating this error). I would be grateful if somebody can fill me in if I have missed any core concept in PHP, thanks.
header.php
<?php
if(true){
echo "Helloworld";
?>
body.php
<?php
include('header.php');
echo "The great brown fox jumps over the lazy dog.";
include('footer.php');
?>
footer.php
<?php
}else{
echo "bye bye";
}
?>
Each file included must be able to be parsed on its own without a syntax error. Your header has a syntax error of an unclosed if block. Likewise, the footer has a syntax error of an else block coming out of nowhere. You cannot do it this way.
Instead you can use something like: