码迷,mamicode.com
首页 > 数据库 > 详细

PHP .htaccess中添加自动加载的PHP文件

时间:2015-09-13 15:45:47      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

[UPDATE:solution] thx everyone, especially RiaD for its idea, this 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.php
php_value auto_prepend_file /home/a7503679/public_html/bin/res/include/init.php

Now all my html files will include that init.php file, so you should (as I did) put there all the common php code you‘ll need on every html page, which in my case was:

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

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

PHP .htaccess中添加自动加载的PHP文件

标签:

原文地址:http://www.cnblogs.com/johnny-tang/p/4804935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!