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

PHP Suddenly stop searching for files in current directory

So I came up against something really strange today. I've updated my PHP APC to the latest version and restarted apache. And then suddenly all scripts in apache starting complaining about not being able to find required files. I would usually…
mobius
  • 5,104
  • 2
  • 28
  • 41
1
vote
3 answers

Variables not holding

I have a .php script with 2 variables. $company and $user. During this .php script I require_once "/var/www/etc/etc/etc/etc/" The .php file that I require_once, the variables from the previous .php script dont' transfer over. I can't figure out…
John
  • 131
  • 1
  • 1
  • 3
1
vote
4 answers

Cron job won't process require_once

I have a Cron job setup to run every 5min. The Cron job is as follows: php /var/www/vhosts/default/htdocs/Mail-test/index.php At the end of my index.php script is the following: $path = $base_path . trim($row['company']) . '/Users/' .…
John
  • 131
  • 1
  • 1
  • 3
1
vote
2 answers

PHP namespaces does away with requiring files?

I was reading over some information on the PHP namespaces released in PHP 5.3, and from what I was seeing it looked like instead of requiring files to get the code you need all you had to do was use a namepace. Am I correct in this assumption?
Brook Julias
  • 2,085
  • 9
  • 29
  • 44
1
vote
0 answers

require_once "System.php"; not working in php 5.6.25

So I'm creating a temporary folder for my extracted ZIP files in server. I tested my code in PHP 7 but unfortunately I needed to run this code in PHP 5.6.25 and system.php doesn't work on php 5 I dont know why. I needed to created a temporary…
kairi
  • 298
  • 3
  • 16
1
vote
0 answers

PHP code, the "include" function is not including the file

As the title says, the include function is not working in a certain part of my code. As another section of the same file uses "include", I know that it is not an issue with this particular file, it is an issue with how I am trying to include it. I'm…
Colleen
  • 13
  • 3
1
vote
1 answer

Can't reference non php files from another folder?

I have a site at https://fixitprobid.com, and in the home directory I have 3 folders: css, js, and diy. Each lead to their respective types of files. so css/styles.css, js/utility.js, diy/install-a-dryer.php (there are many more files and folders…
ioan
  • 295
  • 2
  • 7
  • 23
1
vote
0 answers

Fatal error: require_once(): Failed opening required ... Novice programmer, appreciate any guidance

I'm a novice in server-side programming so any advice is appreciated. I have some PHP files uploaded on a virtual server (000webhost.com) and I'm having trouble with locating a file I'm requiring in another PHP file. The register.php is attempting…
1
vote
2 answers

PHP file path error for autoloader

Here is my file structure on my cpanel webserver root > vendor > autoload.php > public_html > folder > file2.php > script_folder > include_file.php > file1.php Inside…
Austin
  • 1,619
  • 7
  • 25
  • 51
1
vote
1 answer

How to write variables in a php file with html in it?

Hello everyone. I've got a small problem. Instead of making a $content variable and putting in the whole content there, I would like to set the page up like this (below), though the problem is that the php variables that is placed at the end (title,…
Thomas
  • 33
  • 8
1
vote
3 answers

require_once doesn't work in command line

php /home/test9/public_html/degerlendir/test-4567.php "var1=18&var2=22" I need to run one page at background with cron job. I tested my code with command at above. But I get this error: PHP Warning: PHP Startup: Unable to load dynamic library…
eneskomur
  • 91
  • 1
  • 13
1
vote
1 answer

trouble with require_once failed to open stream: No such file or directory

I'm getting the following error when trying to open the index file of a project that I am taking over on: Warning: require_once(core_services/logging.php): failed to open stream: No such file or directory in…
jywbz
  • 11
  • 4
1
vote
1 answer

require_once "piwik.php" outputs "This resource..." in HTML on page

When I call: require_once '/var/www/html/piwik/piwik.php';, I get this output: This resource is part of Piwik. Keep full control of your data with the leading free and open source digital analytics platform for web and mobile. Why is this? Here is…
regor2
  • 107
  • 1
  • 9
1
vote
1 answer

How to include files which names are stored in array in PHP?

I want to simplify files including or requiring process in PHP a little bit, so I wrote the function: $files = array("filename", "other_filename"); function required_files($filenames) { foreach ($filenames as $filename) { …
Daniel
  • 538
  • 1
  • 8
  • 21
1
vote
1 answer

Require_once failed to open stream: No such file or directory

I have this error: Warning: require_once(../questionTypes/Question.php): failed to open stream: No such file or directory in /home/u949913003/public_html/includes/essential.php on line 25 Fatal error: require_once(): Failed opening required…