Questions tagged [php-include]

The `include()` function in PHP includes code from other PHP files and copies them into the file that uses the include statement.

The include() function in PHP includes code from other PHP files and copies them into the file that uses the include statement.

It is identical to the require() function, except that whilst the include function will emit a warning (E_WARNING) when no file is found, the require function will throw a fatal error (E_COMPILE_ERROR), which will cause the script to abort.

Each time a file is included through the include function, the file will be read and executed. To include a PHP script just once, you can use the include_once() function.

252 questions
37
votes
8 answers

How to use a PHP switch statement to check if a string contains a word (but can also contain others)?

I'm using a PHP switch to include certain files based on the incoming keywords passed in a parameter of the page's URL. The URL, for example, could be: ...page.php?kw=citroen%20berlingo%20keywords Inside the page, I'd like to use something like…
sebastian
  • 383
  • 1
  • 4
  • 7
23
votes
3 answers

What's the performance cost of "include" in PHP?

Just wondering if anyone has information on what "costs" are associated with including a LARGE (600K or more) php file containing 100s of class files. Does it really make much difference in comparison to autoloading individual files that for…
FilmJ
  • 2,011
  • 3
  • 19
  • 27
12
votes
3 answers

include(): Failed to open stream: No such file or directory

This might just come as a very silly question, but i am really frustrated of this not working. I have a home file (home.php) which has contains . As it can be seen i am trying to access a file from…
Namit
  • 1,314
  • 8
  • 20
  • 36
9
votes
4 answers

Netbeans does not find all my include_once paths

I've just imported a largish php project into NetBeans. Under the top directory I have "app1", "app2", "app3", etc. (each of which are mapped to a domain name), then a "shared" directory for (you guessed it) files used by all the apps. In…
Darren Cook
  • 27,837
  • 13
  • 117
  • 217
6
votes
1 answer

NodeJS alternative to PHP includes?

I come from a PHP background, but am deciding to try out NodeJS (and probably Express) on my latest project. What is an alternative to PHP includes for templating HTML pages? I'm used to doing: I've tried googling…
LearnSomeMore
  • 440
  • 4
  • 12
6
votes
2 answers

Include PHP and JS files in SuiteCRM

I am using SuiteCRM 7.4.3 and need to include two files (a PHP file and a JS file) into the whole project instance. What are the best practices in this situation? Where should I copy the source files and where do I include them?
Amirhossein Rzd
  • 359
  • 3
  • 12
6
votes
2 answers

Which naming convention is correct for included HTML code fragment files?

I do have an index.php file which includes different parts of the page via PHP. For example this includes the section of the HTML page into the index.php file:
DSC
  • 63
  • 4
6
votes
3 answers

how to exclude a file after including it in php?

After we add a file inside Myfile.php with: require_once 'abc.php'; or include_once 'abc.php'; How we will remove the file? Or how to stop the abc.php file content being accessed after a certain block of code?
user1638279
  • 523
  • 2
  • 12
  • 26
5
votes
4 answers

Setting the path for include / require files

All my PHP include files are in a single directory: https://www.mywebsite.com/includes Inserting these files in top level pages is easy enough:
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
5
votes
6 answers

php templating header and footer

For each page on the site I have a header and footer, so I decided to create a template for both then just include them on each page. contents of the page...
user3040235
5
votes
1 answer

laravel blade @include not working

I am trying to include files in my homepage using blade syntax :- @foreach($data as $articles) @include(app_path().$articles->path)
@endforeach This is not working. The error says :- View…
Stacy J
  • 2,721
  • 15
  • 58
  • 92
4
votes
1 answer

how to include Imagick in PHP

I have a script to delete Exif data from image, I want to use Imagick library, I setup it with : sudo apt-get install imagemagick sudo apt-get install php5-imagick then I wroth this code : $img = new…
user4737789
4
votes
4 answers

How to include php file in drupal 7

I'm coding a form in Drupal 7, and I want to 'include' a php file that adds my DB connection variables to my code. I've tested my code in several ways, and I'm sure that the 'include' makes me get a WSOD when I run Cron in my site. I've Googled…
donbuche
  • 101
  • 1
  • 3
  • 10
4
votes
6 answers

Why does my PHP appear to be commented out when I view it in the browser?

I am building a html page but want to break the header out so I dont have to keep changing all the files. I am attempting to add a php.include file and save the pages out as .php files. For some reason the header.php file is not showing in my file…
Paul Designer
  • 845
  • 1
  • 14
  • 21
3
votes
1 answer

How to PHP-Include from Root of Domain?

I have a file.php located in www.example.com/folder/. I want that file to use include command for files located in www.example.com/include/. If I simply use: It doesn't work, as it will try to search in the…
rockyraw
  • 1,125
  • 2
  • 15
  • 36
1
2 3
16 17