Questions tagged [include-once]

include_once is a PHP statement that evaluates a file during script execution. This tag should only be used to describe problems involving directly the statement, and not because your code appears to use that statement.

include_once is a PHP statement that includes a specified file during script execution. It is similar to , but with the difference that the code from the file will not be executed again if the file has already been included before. Unlike , if an error occurs when including the file, an E_WARNING is emitted which does not halt script execution.

This tag should only be used if your question describes a problem involving directly the include_once statement, or if it is about include_once usage. Do not use this tag just because your code is using that statement.

30 questions
0
votes
3 answers

Warning: require_once(./mailer/class.phpmailer.php): failed to open stream:

Tree: --myproject ----mailer -------class.phpmailer.php ----test -------index.php ----site.php ----class.php ----db.php ----index.php index.php: (both) site.php:
tusa
  • 45
  • 1
  • 8
0
votes
0 answers

Include/require work but include_once/require_once suddenly do not

Several of my PHP (7.2) apps stopped working this morning if they use include_once or require_once, but they worked fine yesterday. The same code also works fine on the same server, but other domains with minimal difference in vhost configs and no…
0
votes
2 answers

Getting error when using a function defined inside a php-file from another php-file

Say, I have a php-file named functions.php like below:
abhi17
  • 33
  • 6
0
votes
0 answers

PHP: Error using include_once function. Failed opening 'mysiteURL' for inclusion

I have never used PHP and need it just to build my WordPress site with an installed theme. Every time when I open any pages under my wp-admin, I'm getting a warning: Warning: include_once(): Failed opening …
gene
  • 2,098
  • 7
  • 40
  • 98
0
votes
1 answer

include_once not working when using in shell script

I am running a php file using shell script like ./first.sh In first.sh I am running a php file using following command COMMAND="/usr/bin/php /home/mydirectory/public_html/members/cron/cron.php" Under cron file I have this…
user3110655
  • 121
  • 3
  • 20
0
votes
0 answers

include_once failed to open stream and Warning: include_once(): Failed opening.for inclusion (include_path='.:/usr/share/pear:/usr/share/php')

I am getting below error . I have already tried with dir , document root, require_once and require. This error i am getting in Live Server. Warning: include_once(/storage/ssd1/655/2980655/public_html/Lib/DB//MysqliDb.php): failed to open stream:…
KishanK
  • 1
  • 2
0
votes
1 answer

Get an error when calling a function from a different include_once file?

I have a structure like so: main.php include_once func1.php include_once func2.php These two files are include'd inside main.php. I get the error below when I call a function switchboard() from func1.php inside finc2.php. Fatal error: Uncaught…
Nikk
  • 7,384
  • 8
  • 44
  • 90
0
votes
0 answers

PHP warning on include_once same file twice

It's normal that I get a PHP warning trying to include_once the same file twice. The first include_once properly loads the PHP file. The second include_once with the same file obviously gives me an error. My question is why am I getting a "Warning:…
Michał
  • 868
  • 1
  • 10
  • 36
0
votes
0 answers

PHP - How does the `require_once` construct executes the code?

I am wondering which one of the following is a better approach when I call require_once(file.php): file.php Header Tag : $name "; ?> OR file.php

Header Tag :…

FreeKrishna
  • 1,833
  • 2
  • 12
  • 21
0
votes
0 answers

require/include throwing warning: no such file or directory in

I'm getting a rather frustrating warning which is blocking me from further development. I've tried using require_once / include_once for a file with a relative path, and it seems to be unable to find it. Then all of a sudden it works, and now it…
kemicofa ghost
  • 16,349
  • 8
  • 82
  • 131
-1
votes
1 answer

include_once works in one page but not other, no errors with displaying_error on

Edit : I'm using bootstrap Edit : When I include bottom and footer in actualites.php ( end of file ) it works. I am bulding a website and I want to include a content by url. So I have :
arshie92
  • 73
  • 1
  • 1
  • 10
-1
votes
1 answer

syntax error, unexpected end of file when using include_once('header.php')

i just installed php 5.6.8 and my older scripts are considered as wrong, getting syntax error, unexpected end of file. On older PHP (5.2-5.3) it worked well, but now I don't know how to fix it to keep the functionality. The basic problem is that in…
-2
votes
1 answer

Why would PHP include_once succeed but require_once, on the same file, fail?

I have a PHP script that uses require_once to load modules. It's run hourly by CRON and was working OK Since adding another module, it still works OK overnight (presumable when the load is low) but frequently fails (crashes) during the day. I…
Mike
  • 1
  • 1
-2
votes
3 answers

PHP include_once not working (have tried almost everything I've found)

Context: I am very new to PHP. My server directory is home/crowdapp/public_html/brand/ In home/crowdapp/public_html/brand/signup.php, I am trying to include two files: home/crowdapp/public_html/brand/includes/signup.inc.php…
-3
votes
1 answer

Implement script within included php file

I am in the process of loading paragraphs from php files, which I then include on my site using the include_once method. The first paragraph loads as soon as the page loads. The problem is: when I try to implement js (jQuery) on certain elements…
ar002
  • 9
  • 2
1
2