John Davidson

php - The includes file does not work when the previous section is hidden

0 comments
Message:


includes("includes/footer.php");


This works perfectly when I have the previous section set to visible. In other words, the rendered page correctly shows the footer.


<section class="visible">
content here
</section>

<?php
includes("includes/footer.php");
?>

BUT when the previous section is set to hidden the footer also disappears (it is not inside the section)


<section class="hidden">
content here
</section>

<?php
includes("includes/footer.php");
?>

The page does not render to include the footer. I can't understand why.
Any ideas?


Thanks.


GH



My Answer:
This issue may be occurring because the included file is not being loaded when the previous section is hidden. One possible solution is to load the included file regardless of the visibility of the previous section. You can achieve this by using PHP to include the file at the top of the page, before any conditional statements that may hide sections.

For example:

php
include('your_included_file.php');
?>



if ($previous_section_visible) {
// Code for the previous section
}
?>


By including the file at the top of the page, it will always be loaded regardless of the visibility of the previous section. This should ensure that the included file is available for use even when the previous section is hidden.

Rate this post

4 of 5 based on 1403 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us