Using PHP strings in PHP includes (novice level)
As a designer, my PHP knowledge is limited to what I picked up over the years that could help facilitate my process. For me, this means pretty much just using includes and strings.
The index files would therefore look something like this (simplified) :
<?php include ('header.php'); ?>
<?php include ('custom.php'); ?>
<?php include ('footer.php'); ?>
It's not ideal — a more common solution would probably have the url insert the custom content into a single-file wrapper (ex: domain.com/article.php?file=93840923) — but I have no idea how to do that; while this is within my limited realm of understanding.
Now correct me if I'm wrong, but if I want to include strings to define header info that is specific to one page (ex: <title><?php echo $title; ?></title>) then I shouldn't define $title; in the custom.php page, because the server reads the includes in order... correct? The head never gets to read the definitions before it has to render them if they're in the body.
So the only way for me to use PHP includes the way I've been using them, as well as strings to define custom header info, would be for me to take the string definitions out of the custom.php file and put them in a standalone file that would be processed before the header. As so...
<?php include ('custom_strings.php'); ?>
<?php include ('header.php'); ?>
<?php include ('custom.php'); ?>
<?php include ('footer.php'); ?>
...right? The reason I had the string definitions in the custom content file in the first place is that I liked the idea of having all the unique non-image data in a single file. But I'm not against separate custom.php + custom_strings.php files.
Could an actual PHP connoisseur confirm the many assumptions I've made in this post, or correct me where I err?
Thanks!
