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

Satisfy 3 conditions in a If/Else statement php page

I need to satisfy 3 different conditions in an if/else statement that require_onces a file in a specific folder My problem is that when my page is loaded my function satisfy only two conditions. I'd like to know if there's a better method to define…
user6315255
1
vote
2 answers

How do I require files in other directory branches?

When I try to use require or require_once, it will work fine if the file to be required is in the same subdirectory, but the moment it sees a file outside of their subdirectory, it generates a fatal error. Here is basically what the file tree looks…
Nik
  • 2,424
  • 3
  • 18
  • 16
1
vote
2 answers

How to save php file as csv file?

script1.php returns results: helen,hunt jessica,alba script2.php returns results: bradley,cooper brad,pitt script.php looks like this and will…
newbie_girl
  • 353
  • 1
  • 3
  • 15
1
vote
1 answer

require_once function error when creating webpage in new folder

I am running wamp64 to locally host my website (it is a vbulletin forums used for testing if that helps at all). I am trying to create a new webpage that is located in a subfolder instead of the root of the website, however I am running into…
1
vote
2 answers

PHP global, nested/inherited autoload

PHP 5.3.3-pl1-gentoo (cli) (built: Aug 17 2010 18:37:41) Hi all, I use a simple autoloader in my project's main file (index.php): require_once("./config.php"); require_once("./app.php"); require_once("./../shared/SqlTool.php"); function…
kagali-san
  • 2,964
  • 7
  • 48
  • 87
1
vote
0 answers

jQuery load html+php in a div

I have this code: $("#tab").load(path/to/php_file); I get this error when executing: Fatal error: Call to undefined function _e() in ... on line 4 Part of the content of this php file:
Toniq
  • 4,492
  • 12
  • 50
  • 109
1
vote
1 answer

require_once() [function.require]: Failed opening required '/vars.inc' (include_path='.;C:\php5\pear')

I have several sites setup on my local machine - customerappglobal, customerapp and naturaleigh. I have just one - customerappglobal - working at the moment because thats the only one I need working. I have added the following code to my httpd.conf…
ClarkeyBoy
  • 4,934
  • 12
  • 49
  • 64
1
vote
2 answers

Codeigniter: using 'require_once' to call a method of one controller from other

I am finding a way in codeigniter to call a method of one controller to other controller I find an article like below: 1. Controller A class A extends CI_Controller { public function __construct() { parent::__construct(); } …
IvanK
  • 65
  • 1
  • 6
1
vote
1 answer

require_once in Moodle (Notice: Trying to get property of non-object in...)

I am trying to write an enrol plugin for moodle and therefor I need the functions of the /moodle/enrol/cohort/lib.php file. But when I try global $CFG; require_once($CFG->dirroot . '../lib.php'); it gives me Notice: Trying to get property of…
Kvasha
  • 37
  • 1
  • 12
1
vote
0 answers

PHP require_once is not working

I am trying to make an interactive php website using MVC framework and on a MAMP server, I am at the first steps of this. I am using the following code to access a different page which has a __construct() function to echo some text... but the…
1
vote
4 answers

Fatal error: require_once():

I'm getting the following error: Warning: require_once(D:/xampp/htdocs/inc/head.php): failed to open stream: No such file or directory in D:\xampp\htdocs\ecommerce1\index.php on line 3 Fatal error: require_once(): Failed opening required …
JOHNNY T
  • 53
  • 2
  • 6
1
vote
3 answers

PHP require problem with "./"

I have a file index.php in root directory: and file common.php in include folder: file globalConfig in the same folder with common.php. The tree folder…
coolkid
  • 543
  • 8
  • 21
1
vote
1 answer
1
vote
1 answer

create variable only once in php

I have been looking for a way to run one piece of code only once in php. I want to create and set a variable at the beginning of the webpage and whenever I call that file, the code will ignore that line. I found this in which there are basically…
smttsp
  • 4,011
  • 3
  • 33
  • 62
1
vote
5 answers

require_once works without include path

I have file 1.php having a require_once for 2.php (both of them are in different folders). The issue I am having is that 1.php seems to magically include 2.php since the path for 2.php is not in 1.php. Just to be sure, I even added a…
pinaki
  • 5,393
  • 2
  • 24
  • 32