Click here to Skip to main content
15,946,158 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to include a php file using require_once but it's not working at all.
It doesn't load that file. Recently I changed php version from 5.6 to 7.2 for my application. I have a backup of this application which uses php 5.6 and all require_once, require and include are working on that application. Any clue why it's not working in php 7.2? Please help

What I have tried:

'require_once' , 'require' and include I tried but no luck
Richard MacCutchan 6-Jun-22 5:25am    
Without more details it is impossible to guess what is wrong. Does the script raise any errors when you try to run it?
Member 15627495 6-Jun-22 6:04am    
require / require_once / include needs to be enclose, but, belonging to the php.ini, the quotes are changing from one setup to another...

in 4 ways : for 3 different setup of server.
the 3 functions involved same writing.

require_once 'myfile.php';
require_once "myfile.php";

you have possibly just a syntax error.. because of " or '

or a wrong path declaration :

require_once('../folder/myfile.php'); / it begins from root here,
but root can be in 'www' or 'parent' root if the server is set to do like that.

To gain a bit, know that include and include once are now deprecated.

require_once is a very good solution, because it load the needed file just one time for all along the script to execute.
It's like 'linking' resource before execution, if you have the same file load 4 times in your code, require_once will load it "1 time" instead of "4". require_once filters the add of external resources. less code in your load, for a gain.

reach the php.ini and read which value between " or ' is ON.
so change it and see your code working again.
Richard MacCutchan 6-Jun-22 6:33am    
You did not mean to post this to me; you should use the Have a Question or Comment? link below.
Member 14362033 7-Jun-22 3:36am    
Hello Richard,
What do I have to change in the php.ini file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900