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
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
  • 373
  • 1
  • 3
  • 14
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
  • 4
3
votes
1 answer

Is there any solution for Sublime Text to import php classes? Something similar to "Fast Import" on Netbeans?

As a php developer i need to instantiate classes all the time. By doing this i need to include or require these classes. I am used to Netbeans IDE where i can easily use the "fast import" option (alt+shift+i). It allows me to use include or require…
Pablo S G Pacheco
  • 2,550
  • 28
  • 28
3
votes
5 answers

How to ignore first line with php include?

I have a php script, which can be run independently from the command line, so it's first line is #!/usr/bin/env php. However, I also have another script, which can automatically run the first one. It does this by calling include 'example.php', which…
Benubird
  • 18,551
  • 27
  • 90
  • 141
3
votes
2 answers

PHP include semantics

I am trying to work out how to interpret PHP's include construct, e.g. whether it is textual inclusion, when it is evaluated etc. As usual, the documentation is rather informal and vague. Based on experimentation, it seems to be syntactic sugar.…
jameshfisher
  • 34,029
  • 31
  • 121
  • 167
3
votes
3 answers

PHP foreach loop separated in two different included files

I need to include an external php file, then execute some code and finally include the final file But since the first file has the beginning of the foreach and the second file has the end of the foreach, it's not working: master script: if…
NaturalBornCamper
  • 3,675
  • 5
  • 39
  • 58
3
votes
2 answers

Old PHP include code not working anymore, how to fix?

Ok so i want to have an include code on my index.php page that will include all of the other html pages within it. I used to do this using an id?=link.html link and this:
Phate
  • 31
  • 2
3
votes
6 answers

Full URL not working with php include

So, I am trying to insert a file with a php include, but for some reason it doesn't work with the full URL. This works: But this does not: Any ideas?
ultraloveninja
  • 1,969
  • 5
  • 27
  • 56
3
votes
2 answers

Failed to open stream no such file or directory. php

I've a file Profile.php which includes Profile_Control.php and the profile_control includes Profile_Model.php . Every things works fine till here. I've another script named Upload.php from which data gets uploaded. This Upload.php also includes…
Mj1992
  • 3,404
  • 13
  • 63
  • 102
2
votes
1 answer

Include a js and css file only in a specific view

In my CodeIgniter application have a common header and footer view, which I include in different views. My header_view is as simple as:
Roman
  • 3,764
  • 21
  • 52
  • 71
2
votes
2 answers

fatal php error: `cannot redeclare function` while using include_once

I have a helper function helper.php with contents: query($sql); } ?> which is included in two files (information.php and commercial.php)…
nluigi
  • 1,263
  • 2
  • 15
  • 35
2
votes
1 answer

What is the difference between include and parsedinclude

What is the difference between using and <%parsedinclude(filename.inc)%> Both work, but I'm curious about the < ? and < % convention, and this is a hard question to phrase for Google. And also the…
Neal
  • 23
  • 3
2
votes
1 answer

HTML PHP Include but need to use different classes

On my web site I have an list that contains about 2 - 5 items depending on the day. The list is stored in the file: menu_upcoming_events.shtml
2
votes
4 answers

Including files from different folders after changing the document root

I am working on a project using WAMP. The vhost is configured like this: ServerName LearningPHP DocumentRoot c:/wamp64/www/learning_php/public/page/ Options…
Mihai
  • 2,807
  • 4
  • 28
  • 53
2
votes
7 answers

PHP include only on homepage URL

I need to include external php file only on homepage of my website. But, since all the pages on the site use the same page template (homepage template), I cant filter them based on that so I was wondering is there a way to include PHP file ONLY on…
1
2
3
16 17