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
0
votes
0 answers

Is there a difference when using brackets in include & require?

When using include/include_once and require/require_once, the PHP docs show examples as such: include 'filename.php'; And also on the same page, users have contributed examples looking like this: include ('filename.php'); As far as I can see, the…
Lee
  • 4,187
  • 6
  • 25
  • 71
0
votes
1 answer

included page is refreshed on subdomains but not on maindomain

I'm currently having a problem on my webpage. The following is present on every page (including the main index.php) Which point to the page with my header.php, which contains
0
votes
1 answer

php accessing variables in constructor from included file

I have a class where I want to use an API, and I've got the api keys in a separate file in another directory. The api key file is literally as simple as this: $id = 'xxxxxxx'; $key = 'xxxxxxx'; This doesn't work: include…
hyphen
  • 957
  • 1
  • 11
  • 31
0
votes
1 answer

How to prevent variables from being used when a file is include() ed

The title is a little confusing, I know. Basically I want to prevent a variable in one file which I include() into another file form being used. Example: File1.php: File2.php: In…
HittmanA
  • 169
  • 5
  • 17
0
votes
1 answer

How Hello Dolly plugin uses Wordpress functions?

I am just starting to learn PHP and WordPress. there is a default simple plugin in WordPress called Hello Dolly.In its file hello.php I can see some WordPress functions like wptexturize() or add_action() but there isn't any include or require…
Saeed Noori
  • 83
  • 2
  • 11
0
votes
1 answer

Why does this require_once fail?

I am using PEAR's Services_Facebook-0.2.14 SDK, and the first of the following lines in Facebook.php fails: require_once 'Common.php'; require_once 'Services/Facebook/Common.php'; require_once 'Services/Facebook/Exception.php'; with the log…
ProfK
  • 49,207
  • 121
  • 399
  • 775
0
votes
3 answers

Are PHP Sessions Associated with Particular Files

Is PHP session data associated with a particular web page or PHP file? In other words, if a session is created in foo.php, would it's session data be accessible from bar.php, assuming that neither reference the other and both are accessed directly…
Laef
  • 1,086
  • 2
  • 11
  • 27
0
votes
2 answers

PHP - Include file and execute code in it

I have this code: <?php echo $title; ?>

Jan Polak
  • 111
  • 3
  • 10

0
votes
4 answers

php include into a variable then echo that variable

I want to include a file entirely into a variable. So that I can call this var multiple times and keep the code as clean as possible. But when I echo the var it only returns a 1 and when I use the include on itself it output the entire file. I want…
purple11111
  • 709
  • 7
  • 20
0
votes
1 answer

How to hide an included php page with css based on media size

I am trying to update my site to responsive. I have several includes in php on a page. Using media queries sizes I want to hide one of them when it is phone size. Is it possible to hide this with css? Thanks for…
Bodine
  • 39
  • 1
  • 9
0
votes
1 answer

PHP how to use relative paths if chained includes

I have the following file system: -dir1 -dir2 -a.php -dir3 -b.php -index.php -dir4 -dir2 a.php -index2.php The two a.php files are not the same! dir1/dir3/b.php includes dir1/dir2/a.php (within a…
Sunshine
  • 1
  • 2
0
votes
0 answers

PHP get_include_path() function

I'm writing a script in PHP, which contains this line: set_include_path(dirname(__FILE__). '/../../../google-api-php-client-1-master/src' . PATH_SEPARATOR . get_include_path()); Locally, in my PhpStorm, the code works. However, when I try run this…
Bramat
  • 979
  • 4
  • 24
  • 40
0
votes
3 answers

PHP: Include methods from one class.php to output variables in another?

Apologies if my terminology isn't correct. I would like to use methods/functions from one class and use them to output variables from another class file. This is my main base: Sphere.class.php
0
votes
1 answer

Multiple "Scripts Calls" within a SINGLE "$(document).ready()"

I must have all my "scripts calls" within a SINGLE "$(document).ready()" . Why I do this : ... ...