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
3
votes
1 answer

PHP Autoloader add Namespace path

My MVC structure is following: - web -- Classes --- Loader.php -- Core --- Controller.php --- Model.php --- View.php --- Bootstrap.php --- DB.php -- Project --- Controllers (folder) --- Models (folder) ---…
Giorgi
  • 609
  • 2
  • 15
  • 29
3
votes
1 answer

PHP / xdebug profiler require_once poor performance

I just started using xdebug to profile my application and immediately noticed something strange in the results. One of the require_once functions is shown to be taking around 12% of the processing time. There are quite a few other calls to…
cdwhatcott
  • 454
  • 2
  • 4
  • 14
3
votes
1 answer

Variable Variables in PHP from required / included files

I am writing a MVC Framework (for the purpose of learning and discovery as opposed to actually intending to use it) and I have came across a slight problem. I have a config.php file: $route['default'] = 'home'; $db['host'] =…
Andrew Willis
  • 2,289
  • 3
  • 26
  • 53
2
votes
2 answers

Require_once doesn't seem to affect all functions?

Everything was working fine in my little project, until I decided to clean up a little bit and moved database-related php-files to their own folder. Then things went strange. I am trying to use two functions here: function getEntries () { …
hannu40k
  • 512
  • 1
  • 8
  • 20
2
votes
4 answers

Is there a HTML variant of require_once?

In HTML is there such a line of code that will do the same thing as PHP's require_once? I'm just curious because there are some lines of codes that I want to duplicate through multiples sheets without needing to require myself to type it each page.…
Matt Ridge
  • 3,633
  • 16
  • 45
  • 63
2
votes
2 answers

PHP - facing problems with require_once() in my site

There's a site I'm developing, and I don't really understand the problem that is occurring... There's a link inside a table in the Home page. When I click on it, It is supposed to provide some GET parameters to the hyperlinked page. The receiving…
maxxon15
  • 1,559
  • 4
  • 22
  • 35
2
votes
1 answer

Require Once stops script

I have a php script, test.php that has the contents and here is the contents of user.php
willium
  • 2,048
  • 5
  • 25
  • 34
2
votes
2 answers

PHP Method Disappears?

I am including one PHP script into another using PHP's require_once() method. This script contains a class, TemplateAdmin, which instantiates itself right after the script, like this: class TemplateAdmin { // Class body... } $templateAdmin = new…
Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
2
votes
1 answer

See the code included in a php file on vscode

Is there a way to see the included code by "included" or "require_once" in the same file without open the included file? Sometimes I would like to have all the final code in the same page.. I usually use vscode, but if there is a way with another…
SciFi
  • 119
  • 7
2
votes
3 answers

To require_once() or Not To require_once()

I am building a PHP CMS from the ground up. There is one super-core file within my system which I currently have automatically importing all other packages and classes that make up the core of the system. On a typical page, only a few of these…
Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
2
votes
1 answer

Process multiple scripts based on variables from Sql

I have an Sql database setup where the e-mail address is compared. If the e-mail address matches then I pull out the Company name, and Name associated with that e-maill address. Ex. example@example.com, John Smith, Quick Company The…
John
  • 131
  • 1
  • 1
  • 3
2
votes
4 answers

Does PHP require, require_once, or include automatically read the file at page load?

I have several pages which use the include or require language constructs within PHP. Many of these lie within IF, ELSE statements. I do realize that a page will not load at all if a require'd file is missing but the main purpose of including this…
JM4
  • 6,740
  • 18
  • 77
  • 125
2
votes
0 answers

dot in require_once somehow replaced by dash

Yesterday I noticed a strange issue with my WordPress website. An uptime monitor reported a 500 error. The logs contained the following error: PHP Fatal error: require_once(): Failed opening required…
redelschaap
  • 2,774
  • 2
  • 19
  • 32
2
votes
3 answers

Including wp-load.php in custom .php file causes page processing to stop. Why ?

I have got a WP website running version 4.8.2. I have created, in the root folder of my theme, a custom php page that includes Wordpress functions with the following code:
Antelion
  • 155
  • 2
  • 14
2
votes
11 answers

How to know if php script is called via require_once()?

My webapp has a buch of modules. Each module has a 'main' php script which loads submodules based on a query sent to the main module: //file: clientes.php //check for valid user... //import CSS and JS... switch( $_GET["action"] ) { case…
alanboy
  • 369
  • 3
  • 15