Questions tagged [include-once]

include_once is a PHP statement that evaluates a file during script execution. This tag should only be used to describe problems involving directly the statement, and not because your code appears to use that statement.

include_once is a PHP statement that includes a specified file during script execution. It is similar to , but with the difference that the code from the file will not be executed again if the file has already been included before. Unlike , if an error occurs when including the file, an E_WARNING is emitted which does not halt script execution.

This tag should only be used if your question describes a problem involving directly the include_once statement, or if it is about include_once usage. Do not use this tag just because your code is using that statement.

30 questions
4
votes
1 answer

include_once(): failed to open stream: No such file or directory - PHP

I was trying to make a simple signup system in php. I have a class called Admin(inside controller folder) which extends the DBConnection.php class. Admin class have a signup method for letting adming signup but got problem there. Error occurs at…
Nishan Dhungana
  • 831
  • 3
  • 11
  • 30
3
votes
1 answer

PHP - variable inclusion not working with include_once inside a namespace

I'm modelling a login page using different schemas (basic username & password combination and another schema using a Yubikey, for now). My controller looks like this: namespace Document { /** * get the current authentication schema */ …
Julio María Meca Hansen
  • 1,303
  • 1
  • 17
  • 37
3
votes
2 answers

Why use include_once when i can just simply type it once

include_once is self explanatory I understand perfectly how it works. I get that it will only include that include ONE TIME. GREAT !!! :) My question is... If i only want that include ONE TIME on my page why am I having to write include_once when I…
3
votes
1 answer

Wordpress - Include_once root files

I'm trying to include some .php files in the header.php of my Wordpress Site. Here is my schema: Root/ |_ includes |_ db_connect.php |_ functions.php |_ var_list.php |_ wp-includes |_ wp-content |_ themes …
Ferrmolina
  • 2,737
  • 2
  • 30
  • 46
2
votes
0 answers

include in PHP. Lowest execution time

I played around with my PHP script and as soon as I made a modification to an include, the execution time decreased 25%. My old include was: include_once "somefile.php"; My new one is: include './somefile.php'; Because of this, I want to try to…
Mike -- No longer here
  • 2,064
  • 1
  • 15
  • 37
2
votes
0 answers

php script works when loaded directly but not when when included using include_once()

I have a PHP file with the following code to detect the user’s country:
Guillermo Carone
  • 818
  • 2
  • 9
  • 24
1
vote
3 answers

Error with PHP 5.6 to PHP 7.2.4. Include_once don´t work

The video illustrating the problem in real time is available here: link: https://www.youtube.com/watch?v=IaTJNS31w6A&feature=youtu.be I have been learning web-development. Newbie in PHP. I created a site in a local server WAMP. By default WAMP uses…
Jeferson Ruiz
  • 19
  • 1
  • 6
1
vote
1 answer

I am using include_once but still getting Cannot redeclare. I know the function exists, that is why I'm using include_once

Ok I am trying to modify some code in a WP Plugin. The plugin declares a file for this: // overwrite hooks $plugin_dir = trailingslashit(dirname(dirname(__FILE__))); if(file_exists($plugin_dir . "auto_overwrite.php")){ include_once($plugin_dir .…
Shane
  • 25
  • 7
1
vote
1 answer

how to deal with include_once php urls?

I'm building a static site and trying to get a bit modular on the code. Using include_once solves my problem, but the new created section.php file is seen as another URL on the server and IMHO creates a SEO problem - duplicate content. Thin theory,…
designarti
  • 609
  • 1
  • 8
  • 18
1
vote
1 answer

php Path not found. Include expression is not resolved

The website Javascript and CSS is not working because included path seems not work, PHPStorm shows that path not found. But the path is correct as image 1: I think the problem is APP_DIR, removed it and PHPStorm did not highlight the path anymore.…
JosephMon
  • 11
  • 3
1
vote
2 answers

PHP - include_once/include not working

I'm working on a very simple CMS system for a school project, and I'm having a bit of trouble. Right now, my webpage is set up as so: Every webpage that I create that a user can access - at the top and bottom, I have an include_once(header.php) and…
0
votes
0 answers

How to include files from other folder

how to include file from the folder who are not in same folder? look at this 2 file addresses: file1 : /includes/folder/folder1/file1.php file2 : /includes/folder/folder2/file2.php so need to include file1 in file2 $purl=…
Behzad
  • 75
  • 1
  • 7
0
votes
0 answers

i am trying to include this page but it is show that there is no such file but it exists

if (isset($_GET['edit'])) { $cat_id = $_GET['edit']; include "C:\xampp\htdocs\BMO\admin\categories.php"; } ?>
0
votes
1 answer

PHP Include_once will include file a second time if a parent directory has a different case

I have a directory structure as follows: test scripts testClasses.php testSubDirectory otherSubDirectory include1.php include2.php includeTest.php Here is the code for each file: testClasses.php:
BluesSax
  • 1
  • 1
0
votes
2 answers

How to solve the fatal error in require_once

My project has two entry point project (root-folder) /config(folder) config.php /service(folder) service.php index.php for example File 1:/index.php ( first entry point) - here we include the config form the config…
1
2