Questions tagged [require-once]
The PHP require_once function
406
questions
0
votes
1
answer
40
views
PHP require_once and paths
I inherited a PHP app that's been developed in Eclipse. While familiarizing myself with the code I noticed something odd. A little background. There are 2 code projects that share Common code. ...
0
votes
0
answers
61
views
PHP require_once behaving asynchronously instead of syncronously
There is a good chance that this has been asked before, but I can't find an answer that works in my situation. I'm a hobby programmer, not a professional developer:-)
I have a client side script ...
0
votes
1
answer
18
views
How to correct an error using require_once() on a live wordpress site?
I've developed an ACF Pro plugin for Wordpress which works fine on my local machine.
When I install the plugin on a live machine however, I get the following error:
[13-May-2023 10:08:14 UTC] PHP ...
0
votes
0
answers
323
views
Target class [App\Http\Controllers\CrudController] does not exist
I'm creating a project in laravel, i have created a controller, and when i try to bind it to the route, it throws an error not found.
CrudController.php
<?php
namespace App\Http\Controllers;
use ...
1
vote
2
answers
70
views
Can't navigate to another page in same language (PHP lang switcher)
I work on a language switcher on a website in PHP. When I change the langauge with the switcher, the navigation menu's language changes, but when I try to navigate to another page
on the nav menu, I ...
-1
votes
1
answer
33
views
require_once: Failed to open stream even with 777 permissions
I have a fairly simple PHP backend where every file is in the same folder.
One of those files is a simple script to login a user
<?php
ini_set("display_errors", "On");
...
0
votes
1
answer
133
views
Insert PHP file in functions.php then echo variables from that file in Wordpress
After trying to find a solution to this, I've decided I'm not bright enough. So, please help.
Here the idea: have a file (ip.php) detect the visitors' country/city, call it once in functions.php (or ...
0
votes
1
answer
225
views
call footer.php from child-theme
I'm quite struggling how to implement the footer.php into the child-them and call it correctly.
In the parent theme it is saved here: theme/header-footer-grid/Core/Builder/Footer.php
I saved the ...
1
vote
2
answers
106
views
Trouble with path for require function in PHP with o2switch host
I have uploaded website to o2switch host.
When I worked on localhost, all worked well.
But on o2switch, I have this error :
Warning: require_once(models/shopManager.class.php): failed to open stream: ...
0
votes
0
answers
79
views
PHP Require_once and after that call a function
2 files: resetMyEvent.php and resetEvent.php
In resetMyEvent.php I need to do a require_once for resetEvent.php
path: admin/resetMyEvent.php
and
path: room/server/updateUserInfo/resetEvent.php
1.First ...
1
vote
0
answers
28
views
Issues With MySql Server Connection Attaching As require_once
When I type in the direct URL to access the page that holds the database connection, db_connect.php on the website, it brings back a message of being successful. When I require it once on my master ...
0
votes
1
answer
221
views
Correct relative paths for require_once()
I wish to better understand which is the safer way to specify require paths in the following cases. Please, tell me if some is wrong.
main.php
includes
|--afile.php
|--bfile.php
classes
|--aclass.php
|...
0
votes
0
answers
41
views
Failed to open stream: No such file or directory. but the file is exactly there
I try to build a little router system in my project and everything should work. but i get this error:
Warning: require_once(../view/homeView.php): Failed to open stream: No such file or directory in C:...
0
votes
1
answer
1k
views
php require / require_once generates ""
I require an extern php file, where just an echo is included, and it works well. The problem is, that the thing  is generated at the top. That produces a clean line in the top.
Do you know ...
1
vote
3
answers
143
views
require_once for bash, but how to for older bash and POSIX-shell?
Inspired by the Php require_once I figured how it could be implemented for modern Bash with associative arrays here:
a.sh
#!/usr/bin/env bash
declare -gAi __REQUIRES
require_once() {
for p; do
...
-1
votes
1
answer
92
views
my other require once php page gets error when i call it in index
I get this error when I try to call product_class.php in index.php. My product_class.php works fine, but when I try to add it to index this error show up:
Warning: require_once(../Includes/config/...
0
votes
0
answers
41
views
cakePHP 3.10 - When NOT using "default" db connection... Controllers cannot find Flash! cakePHP is skipping AppController->initialize()
When working with a "default" db connection the following code works great:
function index()
{
$this->Flash->success("OK???????");
HOWEVER when working with ...
-1
votes
1
answer
536
views
require_once() and require functions not working
I'm developping a Wordpress plugin and i want in my main file in init function to require another page but it's not working, i've tried require(),reqiure_once() and include_once() but none of them ...
0
votes
0
answers
29
views
namespace and require_once amazonpay
i am trying to use amazonpay and encounter the following problem;
when i if ($whatever) require_once("amazonpay_stuff.php") with content:
namespace AmazonPay
require_once "apay/config....
2
votes
1
answer
563
views
See the code included in a php file on vscode
Is there a way to see the included code by "included" or "require_once" in the same file without open the included file? Sometimes I would like to have all the final code in the ...
1
vote
1
answer
451
views
require_once returns true instead of expected object
Both vendor/autoload.php files are basically identical:
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1e055ec2de42b90d5e1653b608643281::getLoader();
In both ...
1
vote
0
answers
980
views
I am getting these errors in laravel while running existing project file on my localhost
Warning: require_once(C:\xampp\htdocs\skillrashtra/public/index.php):
failed to open stream: No such file or directory in
C:\xampp\htdocs\skillrashtra\server.php on line 21
Fatal error: require_once():...
0
votes
2
answers
1k
views
How to solve the fatal error in require_once
My project has two entry point
project (root-folder)
/config(folder)
config.php
/service(folder)
service.php
index.php
for example
File 1:/index.php ( first entry point) - here we include the ...
0
votes
1
answer
354
views
How to prevent phpfmt from removing parentheses from "require_once" statements
I use phpfmt to format the php files according to PSR1 standard.
Every time I use the Format Document function (Shift + Alt + F) in Visual Studio Code, the parentheses have been removed from the ...
-2
votes
1
answer
345
views
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 ...
-1
votes
1
answer
358
views
require_once results in "No such file or directory" error
I'm new to PHP.
Today I tried to require a PHP library called "Ripcord", and it's not working.
I installed the library using Composer, using this command:
% composer.phar require darkaonline/...
0
votes
0
answers
47
views
How to create an object from a class inside another class
I have a problem creating an object from another class inside the constructor of my kernel class, it gives a fatal error which says can not find the class, anybody can help please? I do not know what ...
0
votes
2
answers
853
views
wordpress failed to open stream error whereas working nice in localhost
i am doing in wordpress 5.3 the pulgin for woocommerce is showing this msgs
Warning: require_once(/home/sitename/public_html/1): failed to open
stream: Success in
/home/sitename/public_html/wp-...
-2
votes
2
answers
984
views
Problem to import a function in a file to a class controller in Symfony
I want to add my function handleParameters() into my AuthController but I had "Expected to find a class ... while importing services from resource... but it was not found!"
HandleParameters.php
<?...
0
votes
0
answers
62
views
require_once('page1.php') in page 2 shows page 1 in a whole in page 2 like an iframe
I just wanted to use the input from an other page on the current page to show what the user typed in. But instead the whole page, from which the input comes, appears in the page liek an iframe.
I ...
0
votes
1
answer
45
views
How to use require_once to only load the variables from remote page, then prevent further execution of remote page?
I am using require_once to load some variable values from another page, however, on the bottom of the 'remote' page is another require_once that loads the functions from yet another page.
I am ...
0
votes
3
answers
4k
views
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)
<?php
require_once '../site.php';
?>
...
0
votes
1
answer
139
views
PHP how to avoid load source file on each request?
I have the below API. CityData.php is a file with city and zip which has a size of 100kb. With this function the interpreter loads the file from disk to memory on each request. How can I avoid this ...
0
votes
0
answers
310
views
PHP require_once fails but require works
In an application I am calling require_once $file where I have validated that the $file variable represents an absolute path, the file exists, and is readable. PHP 7.3 is giving me the dreaded: "...
0
votes
0
answers
67
views
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 ...
0
votes
2
answers
55
views
Require_once stopped working after installing mail through pear [duplicate]
so on my Ubuntu 16.04 server, i have a couple of .php files in my /var/www/html/ directory which i do regular php stuff such as data retrieval, user login... etc. I wanted to implement a mail ...
0
votes
2
answers
1k
views
refreshing a div content in 10 sec in wordpress website
I am using WordPress.
I need to refresh a div every 10 seconds. The content of the div is a shortcode, which has an image from an array.
The div name is header_image and the code to create shortcode ...
0
votes
0
answers
821
views
TCPDF - Errors but generating PDF correct
I have a issue with the TCPDF.
When I open the path of the generationFile.php directly everything works fine but each other page gets an error viewed instead of the normal page content:
1) Warning: ...
1
vote
0
answers
456
views
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 ...
0
votes
1
answer
539
views
Class not found after "require_once"
I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line ...
0
votes
0
answers
306
views
Symfony 4, from a method in custom foo class (src/Utils/foo.php), require_one have no effect
I need to load all classes which are in a specific project directory ("dir1/dir2") for list all method (and only list all method, not use them)
I can list all classes but I can't load them and I don'...
3
votes
2
answers
276
views
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 ...
0
votes
0
answers
306
views
php "require_once" includes file twice and fails | htaccess mod rewrite active
I use require_once in different files.
After applying .htaccess redirect rules it still worked flawlessly on localhost but stopped working on the server.
I deleted a require_once line and then it ...
-1
votes
1
answer
74
views
PHP fatal error in require_once() can n
I have a php file in other directory and i wanna use some data of it,but when i require_once() the file i see this error:
Fatal error: require_once(): Failed opening required '/Controller/...
2
votes
0
answers
233
views
dot in require_once somehow replaced by dash
Yesterday I noticed a strange issue with my WordPress website. An uptime monitor reported a 500 error. The logs contained the following error:
PHP Fatal error: require_once(): Failed opening required ...
11
votes
3
answers
1k
views
Eclipse Php : variable undefined evenif it is defined in an require_once php file
I am using as a beginner :
Eclipse IDE for PHP Developers
Version: Photon Release (4.8.0)
Build id: 20180619-1200
OS: Windows 10, v.10.0, x86_64 / win32
Java version: 1.8.0_77
I have a file index.php ...
0
votes
0
answers
413
views
Failed opening required on Cpanel Godaddy
So I need to include a library for my code to work, the following is what gave me the error
require_once "libs\MobileDetect\Mobile_Detect.php";
On my localhost with XAMPP it included the file fine. ...
1
vote
0
answers
94
views
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 ...
1
vote
1
answer
66
views
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-...
0
votes
1
answer
76
views
php sends/echoes '?' for each require_once
My PHP file sends a JSON-Result to some GET-Request.
The problem is, that I keep getting parsing errors on the client side. Looking at the result string I found that each result starts with several ...