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
7 answers

php require_once tries to include a second time on my production server only

I have this code at the top of various include files: require_once("functions.php"); Sometimes I need to include several of my include files to generate a page and on my local server this works fine as the code above tells it to only include…
Dan
  • 2,073
  • 3
  • 22
  • 30
3
votes
2 answers

Can someone please point out why my require_once() function can't find the path? php

I can't seem to find the answer and I have asked everyone I know. On my local server my code worked perfectly fine. When I uploaded it to a server, the require_once(); function stopped working. My file system is very simple. In the main website…
Keet
  • 39
  • 3
3
votes
2 answers

Which is safe, using required once or making one function in helper in codeigniter?

I had one problem while calling controller from another controller,one of the user of stackoverflow suggested to use require_once but another person said it's not a good idea now i'm confused, which is safe ? Using require_once or write a function…
Shibin Raju Mathew
  • 920
  • 4
  • 18
  • 41
3
votes
0 answers

Program stops working after require_once

We have a website that posts data to another website, once that data is send we include a php file. after the php file is included the var_dump doesn't give back the required information ("data received"). I thought it might have been curl at first…
henk
  • 31
  • 2
3
votes
3 answers

Prevent PHP require_once from ever running

Debugging someone else's PHP code, I'd like to selectively override one of their classes. The class is included via: require_once('classname.php'); But, that appears in various places in the application. I'd rather 'simulate' the require_once, so…
benizi
  • 4,046
  • 5
  • 28
  • 25
3
votes
2 answers

Safe to store PHP files above public directory and load them using require_once?

I import website files at the top of each page using: require_once('../file.php'); Is this the correct approach? Or should I be using a different PHP function/approach to access private files? I'm concerned that this approach may be prone to…
user3420034
3
votes
2 answers

PHP Fatal error: Class not found

I've a very strange issue. In one class "SMSNotifier" I have require_once (__DIR__ . "/../InvitationNotifier.php"); [...] class SMSNotifier extends InvitationNotifier { [...] } this class is included in another script which is called from the…
eureka
  • 69
  • 1
  • 7
3
votes
0 answers

require_once does not work - in Zend Framework action methods

I need to integrate Authorize.net payment gateway to my Zf2 application. Downloaded and copied the PHP SDK in php include path. The sdk has the following files +authoriznet +doc +lib +shared +ssl …
Selva
  • 567
  • 2
  • 5
  • 12
3
votes
3 answers

required_once issue in Google API Client for PHP

I have been trying to import/include file in my php script file and somehow it is not working. I know this require_once question has been asked so many times [ 1. require_once with subfolders , 2. require_once() cant find the include path, 3. Using…
3
votes
2 answers

php require_once not working the way I want it to.. relative path issue

I'm having problems assigning a relative path to require_once. I'm sure it's something simple that I'm not seeing... folder directory structure level 1: site level 2: include level 2: class so... site/include/global.php <-- this is where function…
payling
  • 2,466
  • 5
  • 33
  • 44
3
votes
3 answers

PHP find require_once real path

i need to require_once this files main.class.php and functions.php and config.php to admin/test.php. how to php find require real path?! NOTE: main.class.php in class folder , functions.php in includes folder and config.php in root directory and…
B.B King
  • 111
  • 2
  • 3
  • 7
3
votes
6 answers

PHP adds extra whitespace on require

Consider the following code: search.php and category.php are essentially the same structure - a div container with some…
Kai
  • 2,050
  • 8
  • 28
  • 46
3
votes
5 answers

PHP - require_once in multiple pages

I am using LAMP stack to develop a PHP application. I am using require_once to include class files. I need to use the functions in those class files in more than one PHP page. So, I am including those class files in all the required PHP pages using…
sarghau
  • 552
  • 1
  • 6
  • 14
3
votes
4 answers

include, require and relative paths

I'm not sure why I always have some many problems with this. Anyways this is the path to the file I want to require /var/www/vhosts/mysite.com/htdocs/Classes/DBConnection.php This is the path to the file that has the require…
Casey
  • 1,941
  • 3
  • 17
  • 30
3
votes
2 answers

PHP - Debugging Require

I am having some problems using require or require_once in that the code halts execution after the call and I am struggling to find what exactly is causing the problem. I have checked the file exists and can be read (via file_exists and is_readable)…
Mitch Satchwell
  • 4,770
  • 2
  • 24
  • 31