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
2
votes
3 answers

Use of php Include in html files

I'm having some problems on my website using some php code. My site is mainly using html and php. Instead of repeating lots of lines of script at the top of every page, i'm just using the php include statement: I have…
Eddie
  • 611
  • 3
  • 13
  • 23
1
vote
2 answers

PHP OOP, jQuery and MVC

I'm relatively new to PHP OOP and cant seem to be able to call functions in a PHP Class via a controller. My current setup is: index.php class.Class1.php functions.controller.php script.js Within index.php i include class.Class1.php, make a new…
Joey
  • 1,664
  • 3
  • 19
  • 35
1
vote
1 answer

secure php-included file in php code

what is the best method? I use this way... index.php I do not want opens file.php directly. so in first line I wrote this code: file.php
ANDA
  • 163
  • 10
1
vote
3 answers

Include PHP file with condition opened but closed in another included PHP file

I would like to include at the beginning of my script a PHP file that open a IF condition. Then i write my script, and to finish I include another PHP file that close the conditon. This bring me to a "Parse error: syntax error, unexpected end of…
TooLiPHoNe.NeT
  • 479
  • 1
  • 5
  • 22
1
vote
0 answers

Determining doctype inside included php code

I'm making changes to a php script (include.php) that is included by many different PHP scripts which create HTML code (web pages). The developers that maintain those web pages use different doctype, and some are complaining that validator gives…
Ada Lovelace
  • 835
  • 2
  • 8
  • 20
1
vote
1 answer

why is include in my PHP file not including my variables?

I have 3 php files in my Android app - dbConnect.php, which connects with the database, volleyLogin.php, which logs in the user, and UserDetails.php, which gets some info about the logged in user. They work perfectly when running the files in my…
CHarris
  • 2,693
  • 8
  • 45
  • 71
1
vote
0 answers

How to change php include element with js?

I have two headers made in different php files. One header is for index page only and other is for other pages. I included them with php include_once command and i need to set on index page when i scroll to remove first header and show other…
1
vote
1 answer

PHP-inserted text file inside
 tag causing large offset of first line

Im inserting code snippets in my website using the
 tag.
Here is the HTML/PHP code:
    
And here is the content of canny.py: import cv2 img =…
fartagaintuxedo
  • 749
  • 10
  • 28
1
vote
3 answers

When is a php include file parsed?

When is a PHP include file parsed? At startup, or during execution? My web forms call a single php script. Depending on the arguements passed in the URL, a switch/case condition determines what the script will do. Each "case" within the switch has…
user4278933
1
vote
2 answers

Access to files outside of the public folder

For security reasons I want to have all my connection files to the DB and login files in a folder out of the root directory. Like this: Project: includes: conncect.php process_login.php general_files: …
1
vote
2 answers

Add variables to my language system?

I have this language system: $lang = include('lang/en.php'); // default language $lg = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); // detect language if ($lg == "de") $lang = array_merge($lang, include('lang/de.php')); // load german file and…
AlexioVay
  • 4,338
  • 2
  • 31
  • 49
1
vote
3 answers

Php defined functions don't transfer with include

So, I have a file called init.php that is supposed to go on top of every page on my website. In this case it is in my index.php. Inside that init.php is a piece of code that includes all files in a folder called include. When I try to call a…
Somebody
  • 333
  • 3
  • 12
1
vote
1 answer

Included PHP content does not appear to work

I have checked around here and the Internet but I could not solve my issue: First off, I am using the PHP include command to include files from other folders into my various files (I hope that I make sense here). Now to the issue at hand: In terms…
user4399129
1
vote
1 answer

Drupal 7 include php file error

l am working on a Drupal 7 site with a custom video block called a leaf. It allows the admin the ability to add Text, Photos and Video. When I add video, it functions properly, but I get the below error. Strict warning: Only variables should be…
Dave K
  • 11
  • 2
1
vote
2 answers

PHP Include Isn't Including - Woocommerce

The short story, I'm getting php to prove to me that the file exists and is readable but the script simply seems to stop running once the include statement is hit. Also you'll note from the data output further down in this question that I'm using an…
Samuel Hawksby-Robinson
  • 2,652
  • 4
  • 24
  • 25