Announcement

Collapse
No announcement yet.

Get the value from config.php in the file footer.php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get the value from config.php in the file footer.php

    Hi all, how do I get the value from config.php in the file footer.php
    I added a script, the script uses a key, I want to store this key in config.php, but how do I get it in footer.php​

  • #2
    Hey,
    1. Open the config.php file and locate the value you want to retrieve. Ensure that the value is defined as a variable in the file. For example, let's say you have a configuration variable named $database_host with the value 'localhost' in config.php.
    2. In footer.php, include the config.php file at the beginning of the script. This will make the variables defined in config.php accessible in footer.php. You can use the include or require statement for this.
    ​footer.php
    Code:
    <?php
    require 'config.php'; // Now the variables from config.php are accessible here
    echo "Database host: " . $database_host;
    Last edited by Jakub Grufik; 06-14-2023, 06:47 AM.

    Comment

    Working...
    X