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

Is require_once same when you do an output buffering?

I would like a straight forward answer if require_once is same when you do output buffering. Approach 1 1 require_once __DIR__ . '/src/MyBaseClass.php'; Approach 2 1 ob_start(); 2 require_once __DIR__ . '/src/MyBaseClass.php'; 3 …
Allen Linatoc
  • 624
  • 7
  • 17
1
vote
2 answers

Error loading PHP file in Symfony controller

I'm trying to load an authentication PHP file in my Symfony controller. I must use it with require_once (can't copy it). It contains a class for identification on my website. This is what I tried so far: /** * @Route("/login") * @Template() …
Sky
  • 83
  • 1
  • 2
  • 12
1
vote
2 answers

AWS SDK PHP Class Not Found

When I am use the AWS SDK with php I get an error stating that the class cannot be found.
quasar
  • 837
  • 1
  • 10
  • 15
1
vote
3 answers

Can't get root directory for some reason

I'm trying to require some files but it keeps telling me that they can't be found. The files are located in separate folders. index.php -> ../core/init.php -> ../library/autoload.php http://pastebin.com/rG3bvSzn Could anyone help me figure this…
1
vote
2 answers

Require_once across different files, global scope

I've been learning PHP for a couple of days now and I came across a strange issue for me. I have two files : login.php that stores database access data (user, pw, host, db) security.php that have functions that manipulate strings/queries to prevent…
1
vote
1 answer

Why do I get "Warning: require_once(config): failed to open stream: No such file or directory" when trying to run this code?

I'm currently working on programming my very own online store with NetBeans IDE 8.0.2 using PHP. My system is Windows 7 32bit and my localhost is powered by WampServer 2.5. I'm following THC Courses:…
user23524697
  • 137
  • 1
  • 6
  • 18
1
vote
1 answer

PHP site runs on linux but not on windows

I developed a website that runs perfectly on Linux, but when I try to run it on the Windows production server, the php script doesn't work. Everything that's in the code after this line doesn't do anything: require_once __DIR__ . DIRECTORY_SEPARATOR…
efredz
  • 13
  • 2
  • 7
1
vote
2 answers

Include doesn't work?

I want to use a variable from a file in a other file but my include doesn't work. In my file index.php I have a switch: switch ($_POST["Jaartal"]) { case "2010": $dir= "2010"; break; case "2006": $dir= "2006"; …
mr13018
  • 17
  • 5
1
vote
1 answer

How to remove a script included with require after use in PHP?

I'm working with infinite cycles(daemons). Which include the same script for each iteration, the scripts are included with require function. I have a problem, scripts are magnified by each iteration, How could remove the script included after each…
1
vote
2 answers

How to organize require and require once in PHP for class import

I have built a PHP video upload library aimed to be used in different frameworks . ## HERE ##. But i want to make it optimized like , i dodnt want to include or make\ require or require_once call in class and also i want the configuration class to…
Develop4Life
  • 7,581
  • 8
  • 58
  • 76
1
vote
2 answers

php require_once not finding file with absolute path?

I just started setting up the google ads php library and right off the bat am having super frustrating troubles. I'm running Arch Linux, and I have all my files in /var/lib/googleads Trying to run GetRefreshToken.php, it requires a file called…
ryes31
  • 378
  • 1
  • 4
  • 15
1
vote
1 answer

XAMPP Permission Denied for Require_Once Mac OS X Yosemite

Problem: I'm trying to open headerr.php via require_once on a XAMPP localhost server. I'm calling this function through index.php but I keep on receiving the following error message Errors: Warning:…
1
vote
2 answers

Function file will not recognize included PDO database connection

I have a func.php file that contains a function that gets my user's details: require_once 'connection.php'; function getUI($username){ $query = "SELECT * FROM usernames WHERE username = ?"; $sth = $pdo->prepare($query); …
idelara
  • 1,786
  • 4
  • 24
  • 48
1
vote
3 answers

require_once in php

I have a php file which has a require_once Statement (?) this file is then in included in 2 other php files, one php file is in a sub directory so the layout is like this ("file1" and "file2" include the file "included" which require_onces the…
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
1
vote
2 answers

Include Extern Variable inside Method PHP

I have this code: //config.php $EXAMPLE['try1'] = "...." ; $EXAMPLE['try2'] = "...." ; So, i have another file with a php class: class try { public function __construct() { if($this->try1() && $this->try2()){ return true; …
Carbos
  • 117
  • 8