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
1
vote
2 answers

Make content in DIV uneditable

I want to make the contents within a DIV uneditable but still viewable.
The DIV holds the contents of an 'included' file within it. I would like the contents to be viewable…
Mike Badazz
  • 55
  • 1
  • 1
  • 7
1
vote
4 answers

Detect root folder with php

hello there i need help with this. i have two files css1.php and css2.php if the user is on the root folder of the domain i need to include css1.php and if users are inside another like /incomes i need to inlcude css2.php. i want to do this because…
Vohyndra
  • 41
  • 6
1
vote
1 answer

Links to web pages that are php includes goes back to home page

I don't profess to be any good at php, so those who are expert please don't bash me for my noob approach. I am trying to learn. Some time back, I had someone show me how to break up parts of my web pages and write them as includes so that I wasn't…
Heidi
  • 11
  • 1
1
vote
0 answers

Why is declaration of class in file included in separate function clashing with include in other function? (example code included)

My understanding of including a file in a function was that it stays within that function scope: If the include occurs inside a function within the calling file, then all of the code contained in the called file will behave as though it had been…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
1
vote
9 answers

How to change an include file depending on the page

I'm making a website and for all of the pages I've including header.php, which is just a logo and navigation bar at the top of the page, below is the code for the nav menu.
1
vote
0 answers

How to reduce page loading time when we have to make several XMLHttpRequest simultaneously using jquery load statement?

I have a template page named as 'career_new.php'. I want to use this template for my several pages related to different careers such as CA, Engineering, MBA etc. For this I have written the code which is appearing below this paragraph. This code is…
1
vote
1 answer

PHP include: failed to open stream: no such file in "/literally/the/exact/location/of/the/file"?

So while trying to include a file in php, using include(/Users/leonaves/Sites/mysite/admin/inc/pages/dashboard.php) (I'm running locally), PHP tells me: Failed to open stream: No such file or directory in…
Leon Aves
  • 739
  • 1
  • 7
  • 24
1
vote
2 answers

php global variable doesn't work inside included file

I've searched for a day to find a solution for this,But no luck yet, I have a function called : online() this function is inside a file called client.php which is located in root/dir/includes/client.php: In client.php: // db connection include…
Ramtin Gh
  • 1,035
  • 2
  • 11
  • 31
1
vote
4 answers

PHP: including 2 same php files in 1 page

i have a code

Clients / Projects

Treby
  • 1,328
  • 6
  • 18
  • 26
1
vote
2 answers

PHP include() creates unwanted gaps in HTML

I have a document that includes a header (menu) and a footer in PHP: For some reason when opened on the browser it renders a gap between both without having any margins or CSS styles…
multimediaxp
  • 9,348
  • 13
  • 49
  • 80
1
vote
3 answers

Opencart module include custom php file issue?

I'm trying to create an OpenCart 1.5.1.3 module. The issue I'm having is with including a custom php script. When I do this in the controller: include('module/simple_html_dom.php'); or include('simple_html_dom.php'); I'm presented with the…
JasonMortonNZ
  • 3,752
  • 8
  • 34
  • 56
0
votes
1 answer

PHP: Can't access a definition from an included file?

I have a file file_to_include.php that contains variable definitions, define("NAME", "John Doe"); But when I try to include it in my other file, index.php, using include_once 'file_to_include.php'; and then echo my definition in index.php…
user7158855
0
votes
4 answers

PHP Include - Error Fixing

I have the following PHP code that produces an error as the include files don't exist. I have not yet made them but I want to stop errors being produced (not just hidden). Is there anything I can put into my code that says "don't record any errors…
user7334492
0
votes
0 answers

loading include php inside bootstrap

I have html code and it is working fine, but when I use "include" file.php bootstrap nav does not work. The user menu - dropdown-menu is not working.
Abigail NE
  • 13
  • 2
0
votes
1 answer

includes not working easyphpdev server

I am running easyPHP Devserver 16.1.1 and having a bit of trouble with this local server, it won't show me any PHP locally. I've tried reinstalling it but that doesn't help. The program runs just fine, shows all the HTML I've got in the site but…