include_once not working.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prabhas
Forum Newbie
Posts: 2
Joined: Thu Sep 11, 2008 12:49 am

include_once not working.

Post by prabhas »

I have some php scripts to work with. The main script (main.php) includes some another php script (say script1.php), and this script1.php in turn includes yet another script (say scrip11.php). The second include (of script11.php) is inside a function func1 written in :D script1.php file. The script1.php gets included correctly inside main.php, but the second include_once statement (in file script1.php) is not working.

I tried to check this several ways, the options I used are listed below:
1) check using function_exists, called on the function from script11.php
2) check putting simple echo statements in all the scripts.
3) check using include_once return value. --> if(!@include_once('script11.php')) die("failed");

But none of the above could point me to the error, except they only confirmed that include_once is not working there.

Moreover, even the statements after include_once are also not executing.

Please help me out of this trouble.

Thanks in advance!
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: include_once not working.

Post by marcth »

Code: Select all

<?php
//In your constants files
define('PATH_XYZ', 'absolute/path/to/directory/'; 
define('PATH_ABC', 'absolute/path/to/directory/';
 

Code: Select all

 
//at the top of your files
require_once(PATH_ABC . 'boo.php')
 
prabhas
Forum Newbie
Posts: 2
Joined: Thu Sep 11, 2008 12:49 am

Re: include_once not working.

Post by prabhas »

I set some parameters in the PHP.INI file and it worked fine for me. :P
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: include_once not working.

Post by onion2k »

Never use error suppression during development. By using @include_once you're hiding the very error message that you need to see.
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: include_once not working.

Post by marcth »

prabhas wrote:I set some parameters in the PHP.INI file and it worked fine for me. :P
If you modified you include_path in php.ini, you're just asking for trouble down the road.
onion2k wrote:Never use error suppression during development. By using @include_once you're hiding the very error message that you need to see.
Onion2k makes a very good point there.
Post Reply