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.

253 questions
29
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
  • 303
  • 1
  • 4
  • 7
22
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
  • 1,931
  • 3
  • 18
  • 25
11
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,264
  • 7
  • 18
  • 34
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
  • 24,365
  • 12
  • 95
  • 193
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
  • 322
  • 3
  • 9
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
  • 259
  • 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
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
  • 265,915
  • 79
  • 461
  • 583
5
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
  • 503
  • 2
  • 9
  • 25
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,463
  • 11
  • 47
  • 83
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
  • 89
  • 1
  • 3
  • 8
3
votes
1 answer

How do I pass a dynamic PHP variable from one page to another?

I am creating 2 webpages. The first one will show a list of items. 2nd web page, I want to create a general one so that when the user clicks on an item depending upon the chosen one, 2nd page will be modified as per item. I just want to pass a…
sharin gan
  • 315
  • 1
  • 2
  • 12
3
votes
5 answers

Include Functions PHP

I have a Php file for include functions and a css page. I am trying to make a include function to generate most of my html. I just can not figure out how to get the css file to be in the php include function I made.
Zack
  • 37
  • 3
3
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
1
2 3
16 17