Add an automatically loaded PHP file in PHP. htaccess

Source: Internet
Author: User

[Update:solution] thx everyone, especially RiaD for the IT idea, which is what I've done:

edited my. htaccess file at the root of my website and added the following line,

#Loads an init php located at <fullpath>/<path-to-folder-with-php-files-to-include>/init.phpphp_value auto_prepend_file /home/a7503679/public_html/bin/res/include/init.php

Now all my HTML files would include that init.php file and so should (as I do) put there all the common PHP code you ll n Eed on every HTML page, which in my case was:

<?phpdefine("PHP_ROOT", "/home/a7503679/public_html/bin/res/include/"); #this solves the probleminclude ‘lang.php‘; #translations file?>

Before I needed to include this on lang.php every page and now it's automatically done. If I need to include any other PHP file with the using its absolute path, I just typeinclude PHP_ROOT.‘filename.php‘;

Add an automatically loaded PHP file in PHP. htaccess

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.