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
1
vote
2 answers

Error linking file while everything looks fine

I am having a problem in linking the file. I am sure that I have no problem from my side as I have checked everything from my side. Here is what I have uploaded(via FileZilla), While on the website it displays that it can not find this…
user379888
1
vote
2 answers

how to include a php function in a class?

i have a class: class Connect { public function auth() { ... do something } } and i have a function: getfile.php the i have the: connect.php
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
1
vote
2 answers

How to auto include files with php not OOP?

I have different mods such as users, statistics and etc. If I click over users I get information about users, if I click statistics I get user statistics and so on. But I want to do that automatically with php (not OOP) - auto include and call…
Someone
  • 736
  • 2
  • 12
  • 29
1
vote
2 answers

Can't navigate to another page in same language (PHP lang switcher)

I work on a language switcher on a website in PHP. When I change the langauge with the switcher, the navigation menu's language changes, but when I try to navigate to another page on the nav menu, I get the following error message, and the ?lang=…
1
vote
1 answer

How do you use a require_once header for items in a different folder?

I use require_once("header.php"); for all pages of my website. Though, I feel like I can only use that code for files filed directly under the public_html folder. If I use the require_once("header.php"); code for any other files located in a…
Andrew
  • 11
  • 2
1
vote
2 answers

How to block to call function pages' outside required pages in PHP

I have a simple config page in my root directory. It's similar wp-config.php which in wordpress system. It's name is config.php (or anything). There are some mysql logins or general page functions in my files(functions.php). When user calls my index…
Benjamin
  • 2,073
  • 4
  • 18
  • 16
1
vote
2 answers

Trouble with path for require function in PHP with o2switch host

I have uploaded website to o2switch host. When I worked on localhost, all worked well. But on o2switch, I have this error : Warning: require_once(models/shopManager.class.php): failed to open stream: No such file or directory in…
1
vote
0 answers

Issues With MySql Server Connection Attaching As require_once

When I type in the direct URL to access the page that holds the database connection, db_connect.php on the website, it brings back a message of being successful. When I require it once on my master header page to determine what to show the website…
user18106064
1
vote
3 answers

require_once for bash, but how to for older bash and POSIX-shell?

Inspired by the Php require_once I figured how it could be implemented for modern Bash with associative arrays here: a.sh #!/usr/bin/env bash declare -gAi __REQUIRES require_once() { for p; do r=$(readlink --canonicalize-existing "$p") #…
Léa Gris
  • 17,497
  • 4
  • 32
  • 41
1
vote
1 answer

require_once returns true instead of expected object

Both vendor/autoload.php files are basically identical: require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit1e055ec2de42b90d5e1653b608643281::getLoader(); In both files: $composer_object =…
MikeiLL
  • 6,282
  • 5
  • 37
  • 68
1
vote
0 answers

I am getting these errors in laravel while running existing project file on my localhost

Warning: require_once(C:\xampp\htdocs\skillrashtra/public/index.php): failed to open stream: No such file or directory in C:\xampp\htdocs\skillrashtra\server.php on line 21 Fatal error: require_once(): Failed opening…
Naman Mehta
  • 41
  • 1
  • 8
1
vote
2 answers

How to debug a class redefinition in PHP?

I'm getting a PHP Fatal error: Cannot redeclare class Foo in /directory/ on line 20 error, but I have no idea where it's coming from. I'm always using require_once for this class file, and I'm not sure how to debug it. Can I get some kind of…
Lazlo
  • 8,518
  • 14
  • 77
  • 116
1
vote
2 answers

php - require, require_once, include - page loaded twice

I have a question. I have file1.php in includes directory - so includes/file1.php Another file is file2.php that have a require(dirname(__FILE__).'/includes/file1.php'); I've looked with firebug, and also I wrote something into a txt file, and…
user760821
  • 21
  • 2
1
vote
4 answers

Question about including files with require_once

I have downloaded this API. If you go to lib/Paypal/Profile/Handler/Array.php you will find this line: require_once 'PayPal.php'; Since the PayPal.php file is in the lib/ folder, I expected something like this: require_once…
tirenweb
  • 30,963
  • 73
  • 183
  • 303
1
vote
1 answer

Codeigniter controller in subfolder extends outside one

Is it possible a controller inside a subfolder, lets call it 'category', extends from a controller from the parent folder? Example: application_controller.php in the controller folder category in the folder controller/category It keeps me showing…
Elkas
  • 603
  • 12
  • 27