Jump to content

require_once


Zepx

Recommended Posts

Hi,

 

I'm facing a very weird problem. First I would like to explain what is going on.

 

1. I have a first.php script that does a require('settings.php'); and another second.php script that does a require_once('settings.php');

 

2. The idea here is to load settings.php and output the variables inside of it. It also has 3 functions.

 

The problem is when both of first.php and second.php script loads together, the settings.php gets loaded once, but I can't echo and variables from settings.php from my second.php script.

 

I had onced tried both files using required() but I got an error saying that I'm not allowed to redeclared the functions that were already declared. So I knew I had to use require_once(). But it's not working like how I want.

 

For those who can't get what I mean, please check out this two links,

 

http://zepx.co.cc -- The homepage, if you look at the sidebar, under New Links, you should see that the output works fine.

 

http://zepx.co.cc/links/ -- Now, look at the sidebar, it's showing errors. It says that I'm using File() but there was no parameter in it, that is because I took the parameter from settings.php, which resulted an empty string.

 

Also, as you can see at http://zepx.co.cc/links/ , the page has 2 php scripts, one was loaded in the content, and the other in the sidebar.

 

I'm not sure if my explaination was clear. If it's not, I'll try to restructure my sentences.

 

Regards,

Zepx

Link to comment
https://forums.phpfreaks.com/topic/181398-require_once/
Share on other sites

Hello!

 

I Get a 404 for http://zepx.co.cc/links/

 

I, along with most of the PHP programmers I know, will always use require_once();

We usually use that simply because if it is loaded, you do not want an error returned if it was already included.

 

Maybe try switch both to require_once(); and see if your problem still exists.

 

If it does, see if you can get the webpage working because a live example is like a picture...worth 1000 words!

 

Ryan

Link to comment
https://forums.phpfreaks.com/topic/181398-require_once/#findComment-956896
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.