How to include a PHP file in all other PHP site files?

Hi, I need to include a PHP file in all other PHP files of my site.

This is a sample of my site map:

|index.php
|foolder1
||    file1.php
||    check.php
|foolder2
||    file2.php
|foolder3
||    file3.php

I want the whole PHP file to be included check.php, I have to say that I can’t edit php.ini, and I know what it is php_value auto_prepend_file "check.php", but I don’t know how this function is launched, then I ask for help to use php_value auto_prepend_fileor another way to include my file in all the others PHP files? Thank you in advance.

EDIT:

I know that in StakOverflow have some questions, like this one, but I can not edit your php.ini (some restrictions on the server ...), and I just tried to put php_value auto_prepend_file "foolder1/check.php"in .htaccess, and it is run on index.php, but not to file1.php, file2.php.. .

+4
2

.

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Explicitly disable rewriting for front controllers
    RewriteRule ^app_dev.php - [L]
    RewriteRule ^app.php - [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>

- app.php, .

// app.php
//
// Do shared steps like setup the database

switch($_SERVER['REQUEST_URI']) {
  case "foo/bar":
    require "foo/bar.php";
    break;
  case "baz/woo":
    require "baz/woo.php";
    break;
  default:
    require "404.php";
}

, URL: s , URL-, .

+1

, apache2.

Ubuntu 14.04

etc/apache2/sites-available/000-default.conf

VirtualHost

php_value auto_prepend_file "/var/www/html/check.php"

Apache.

: .htaccess, .

2

1).htaccess .htaccess Apache Ubuntu

2) check.php

0

Source: https://habr.com/ru/post/1621867/


All Articles