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.

31 questions
3
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…
Elon Musk
  • 758
  • 7
  • 25
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,223
  • 1
  • 15
  • 35
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 …
Fernando Molina
  • 2,709
  • 2
  • 25
  • 42
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,016
  • 1
  • 11
  • 26
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
  • 707
  • 8
  • 20
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
  • 569
  • 6
  • 18
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 echo the image path using require_once?

Files: job/main.php job/require/nav.php job/images/submenu_regular_visit.png Step: show the submenu_regular_visit.png using relative path at nav.php. require_once("require/nav.php") at main.php Expect: show submenu_regular_visit.png at main.php…
0
votes
0 answers

How do I call the horizontal menu in any Java Spring MVC code? Is there an analogue of php's include_once in Java Spring MVC?

I developed a project with a horizontal menu (HTML+CSS) in php. Now developing a new project on Java Spring MVC + Postgresql. I'm a new in Java Spring MVC and have one question: In php, I can call horizontal menu anywhere in the php code, for…
ACDC71
  • 1
  • 1
0
votes
0 answers

Wordpress shortcode - include_once cant find file in "includes" folder? php, mysql

The plugin "Shortcoder" in Wordpress doesent fint the included file? Anyone that knows how to find where the page with the embedded shortcode is located in the folder hirarki? I have tested all from "/includes/book.." to "../../../includes/" but i…
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 3