Questions tagged [require-once]

The PHP require_once function

The PHP require_once function.

In contrast to require this function only includes the referred file if it has not been included before.

Use this tag only for questions that directly ask about require_once usage. Do not use this tag if your code contains require_once but you have no reason to believe that require_once is directly related to the issue you are asking about.

409 questions
2
votes
1 answer

Can't include a file named "config.php" in my PHP app (it gets ignored)

I have the following dir structure: /app /controlers /models /views init.php config.php /www index.php /www/index.php code to call the init file: include_once '../app/init.php'; Then in /app/init.php I have: require_once…
GWS
  • 33
  • 3
2
votes
3 answers

Joomla3.6 Fatal error: require_once(): Failed opening required

We have moved web hosting provider and moved our joomla website and database across. When trying to access the front end of the website, I get the error: Warning: require_once(JPATH_BASE/libraries/import.legacy.php): failed to open stream: No such…
KEmu
  • 21
  • 1
  • 3
2
votes
2 answers

Laravel 5.4 and WordPress 4.7 conflict in helper function __()

I am developing a website using Laravel, with a WordPress Blog section running in parallel and independently. Since Laravel 5.3 everything run smoothly, using a Service Provider I was able to include 'wp-load.php' with a require_once() call and use…
Marco Cazzaro
  • 661
  • 8
  • 13
2
votes
2 answers

Choosing different versions of Zend Framework to load using Zend_Loader and it's issues

Okay, so, I wanna be able to choose different versions of Zend Framework (and other frameworks) using Zend_Loader. Well, the code isn't tricky at all, but the problem is, there are so many require_once lines in the framework itself that would…
Cg Alive
  • 639
  • 1
  • 6
  • 11
2
votes
0 answers

Does the require_once behavior change when moving from PHP Version 7.0.0RC5 to PHP Version 7.0.11?

I started migrating my applications to PHP7 last year already using the PHP7 release candidate (7.0.0RC5) available at the time. I successfully made all required changes and the apps are all running fine on that version (PHP 7.0.0RC5). Recently I…
bluegrass
  • 46
  • 4
2
votes
2 answers

PHP: require_once and inheritance

If I have: require_once("bla.php"); class controller{.....} If I then create in a different file class control_A extends controller{...}, do I need to again say require_once("bla.php");, or is it inherited? What if the require_once is done inside…
JDelage
  • 13,036
  • 23
  • 78
  • 112
2
votes
1 answer

laravel access native php script

I'm trying to run a native php script using laravel routes.php , view, controller. but no chance. for example if i have a test.php inside views path and require it in a view blade: then build a route to that…
alex
  • 7,551
  • 13
  • 48
  • 80
2
votes
3 answers

Warning and Fatal error calling require_once()

I want to fetch div element from other website . on which iam having my profile, i have tried using this…
saif
  • 43
  • 6
2
votes
2 answers

Approaching dynamic php includes on legacy projects without a front controller

Dependency management via Includes/require_onces in php is a pain. Every once in a while I change things and stuff breaks and I have to rethink my approach to initializing the very first include()/require() in php. I feel like I'm missing a more…
Kzqai
  • 22,588
  • 25
  • 105
  • 137
2
votes
4 answers

Optimizing PHP require_once's for low disk i/o?

Q1) I'm designing a CMS (-who isn't!) but priority is being given to caching. Literally everything is cached. DB rows, DB id queries, Configuration data, processed data, compiled templates. Currently it has two layers of caching. The first is a…
buggedcom
  • 1,537
  • 2
  • 18
  • 34
2
votes
3 answers

PHP require_once() .js file

Okay, so I'm using require_once to load the contents of a .js file. However, there seems to be a 1 added to the end of the file after the require is done. PHP: echo require_once("test.js"); JS: var newFunc = function() { …
CJT3
  • 2,788
  • 7
  • 30
  • 45
2
votes
1 answer

Symlink - require_once doesn't seem to work?

I store my WordPress theme in my Dropbox to use it easily on many machines. Unfortunately require_once()/include_once() doesn't seem to work for me. Is store original theme at G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\ The symlink is placed at…
Wordpressor
  • 7,173
  • 23
  • 69
  • 108
2
votes
2 answers

require_once $_SERVER['DOCUMENT_ROOT'] . '/defines.php'; not working

Is it possible to use require_once $_SERVER['DOCUMENT_ROOT'] . '/defines.php'; I keep getting an error on it. I tried require_once ($_SERVER['DOCUMENT_ROOT'] . 'htdocs/comments3/defines.php'); but it still won't work please help me. im trying to…
Katsuragi
  • 21
  • 1
  • 4
2
votes
3 answers

PHP - require_once and class inheritance issue

I get a fatal error: Fatal error: Class 'Foo1' not found in .../Foo2.php on line 5 with the following…
Alban Soupper
  • 671
  • 1
  • 5
  • 20
2
votes
1 answer

Can't call classes if they are in another php file?

I am attempting to call a class in a required file, but I am getting the error PHP Fatal error: Class 'SampleClass' not found in /home2/domain/public_html/website/v2/wp-content/plugins/myplugin.php on line 23 I can tell that the file is required…
Sam
  • 6,616
  • 8
  • 35
  • 64