dezkit Posted December 1, 2008 Share Posted December 1, 2008 Is it possible to make it so that a php file will get included into every other php file in a website? (without using include function) By that i mean: file.php <?php echo "hello "; ?> file2.php <?php echo "world."; ?> and file2.php is going to say "hello world." Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/ Share on other sites More sharing options...
trq Posted December 1, 2008 Share Posted December 1, 2008 You can set it within the auto_prepend_file directive either within the php.ini itself or your .htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702791 Share on other sites More sharing options...
dezkit Posted December 1, 2008 Author Share Posted December 1, 2008 how can i use this in .htaccess? (has to be included in every php file in every directory) thanks sooooo much Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702797 Share on other sites More sharing options...
trq Posted December 1, 2008 Share Posted December 1, 2008 php_value auto_prepend_file "/path/to/file.php" Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702800 Share on other sites More sharing options...
dezkit Posted December 1, 2008 Author Share Posted December 1, 2008 I get a 500 internal server error using that errorlog says: "/home/cobi/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration" Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702804 Share on other sites More sharing options...
trq Posted December 1, 2008 Share Posted December 1, 2008 Post your .htaccess Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702811 Share on other sites More sharing options...
dezkit Posted December 1, 2008 Author Share Posted December 1, 2008 ErrorDocument 404 /404.html RewriteEngine on RewriteRule ^([^/\.]+)/?$ /$1.php [L] php_value auto_prepend_file "include.php" (I know it supposed to say file.php, the real filename is include.php) Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702813 Share on other sites More sharing options...
trq Posted December 1, 2008 Share Posted December 1, 2008 Sorry, I don't see anything wrong with that. The only thing I can think of is that your using php as cgi and not a an apache module. You'd need to check your phpinfo to see, if thats the case you can't use .htaccess toset php directives. Youy should however be able to create and use a local php.ini Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-702815 Share on other sites More sharing options...
dezkit Posted December 1, 2008 Author Share Posted December 1, 2008 Hmmm, should i contact my host? Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-703422 Share on other sites More sharing options...
dezkit Posted December 1, 2008 Author Share Posted December 1, 2008 Topic solved: I just edited the php.ini code in my root directory on my server. Thanks so much thorpe. Quote Link to comment https://forums.phpfreaks.com/topic/134950-solved-including-the-same-file-in-every-php-file/#findComment-703464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.