This is a discussion on require_once dying silently within the PHP General forums, part of the PHP Programming Forums category; Hi, everyone. This one's been driving me bonkers for an hour now. Anyone have any idea why require_once would ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, everyone.
This one's been driving me bonkers for an hour now. Anyone have any idea why require_once would be dying silently in the script below? ------------------------------------ $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk"; $CFG->dataroot = $CFG->dirroot.'/moodledata'; require_once("$CFG->dirroot/lib/setup.php"); ------------------------------------ I've confirmed that the file setup.php exists and is readable. I've got error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself produces absolutely no output, even though it will produce output galore when I put in a deliberate syntax error. I've also tried: ------------------------------------ require_once($CFG->dirroot."/lib/setup.php"); ------------------------------------ but this didn't help. Any assistance at all would be greatly appreciated. -- Richard S. Crawford (rscrawford@mossroot.com) http://www.mossroot.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com) |
|
|||
|
Richard S. Crawford wrote:
> Hi, everyone. > > This one's been driving me bonkers for an hour now. Anyone have any idea > why require_once would be dying silently in the script below? > > ------------------------------------ > > $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk"; > $CFG->dataroot = $CFG->dirroot.'/moodledata'; > > require_once("$CFG->dirroot/lib/setup.php"); > ------------------------------------ > > I've confirmed that the file setup.php exists and is readable. I've got > error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on > Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself > produces absolutely no output, even though it will produce output galore > when I put in a deliberate syntax error. Syntax errors in which file? The calling one (where you have the require_once) or the lib/setup.php file? Maybe something in your code is disabling your error reporting, I'd put both: error_reporting(E_ALL); ini_set('display_errors', true); in before the require_once and see what happens. -- Postgresql & php tutorials http://www.designmagick.com/ |
|
|||
|
<?php echo 'begin brainstorm.'; ?>
Is it possible that something is "going wrong" between the definition of $CFG->foo and when you require that could cause $CFG->dirroot to be null? Then it would point to /lib/setup.php, which definitely shouldn't exist and should thus throw an error, but maybe it's worth looking into. <?php require_once('Have you tried including a file that definitely does not exist?'); ?> That would rule out any error reporting problems anyway. Have you tried something to the effect of <?php echo __FILE__ . ' included'; ?> on the first line of setup.php? Adding <?php print_r(get_included_files()); ?> after the require_once() might also help. > I've confirmed that the file setup.php exists and is readable. I apologize if this seems obvious, but for the sake of brainstorming... it's readable by the user running apache, right? And even if it weren't, that should have thrown an error *shrugs* That's all I can think of. I hope it is of some use to you. <?php echo 'end brainstorm.'; ?> <?php signature('GREG'); ?> |
|
|||
|
On Tue, Apr 8, 2008 at 8:27 PM, Greg Bowser <topnotcher@gmail.com> wrote:
> <?php echo 'begin brainstorm.'; ?> > > Is it possible that something is "going wrong" between the definition > of $CFG->foo and when you require that could cause $CFG->dirroot to be > null? Then it would point to /lib/setup.php, which definitely > shouldn't exist and should thus throw an error, but maybe it's worth > looking into. > > <?php require_once('Have you tried including a file that definitely > does not exist?'); ?> That would rule out any error reporting problems > anyway. > > Have you tried something to the effect of <?php echo __FILE__ . ' > included'; ?> on the first line of setup.php? Adding <?php > print_r(get_included_files()); ?> after the require_once() might also > help. > > > > I've confirmed that the file setup.php exists and is readable. > I apologize if this seems obvious, but for the sake of > brainstorming... it's readable by the user running apache, right? And > even if it weren't, that should have thrown an error *shrugs* > > That's all I can think of. I hope it is of some use to you. > > <?php echo 'end brainstorm.'; ?> > > <?php signature('GREG'); ?> > > You should try: <?php require_once("/home/rcrawford/public_html/tanktrunk/tanktrunk/lib/setup.php"); ?> -- -Casey |
|
|||
|
Richard S. Crawford Ã*rta:
> Hi, everyone. > > This one's been driving me bonkers for an hour now. Anyone have any idea > why require_once would be dying silently in the script below? > > ------------------------------------ > > $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk"; > $CFG->dataroot = $CFG->dirroot.'/moodledata'; > > require_once("$CFG->dirroot/lib/setup.php"); the above won't work, as the parser will try to interpret $CFG and put it in the string first, then go ahead. try this: require_once($CFG->dirroot."/lib/setup.php"); or this: require_once("{$CFG->dirroot}/lib/setup.php"); greets, Zoltán Németh > ------------------------------------ > > I've confirmed that the file setup.php exists and is readable. I've got > error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on > Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself > produces absolutely no output, even though it will produce output galore > when I put in a deliberate syntax error. > > I've also tried: > > ------------------------------------ > require_once($CFG->dirroot."/lib/setup.php"); > ------------------------------------ > > but this didn't help. > > Any assistance at all would be greatly appreciated. > |
|
|||
|
Richard S. Crawford wrote:
> Hi, everyone. > > This one's been driving me bonkers for an hour now. Anyone have any idea > why require_once would be dying silently in the script below? > > ------------------------------------ > > $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk"; > $CFG->dataroot = $CFG->dirroot.'/moodledata'; > > require_once("$CFG->dirroot/lib/setup.php"); > Hi, It reads as if $CFG is an object and ->dirroot is not a public property of that object. So, I don't know what $CFG is, but I think the problem lays there. Also, OOP is nice and all (not to start a thread about OOP again), but putting your config into an object seems a bit overdo to me. -- Aschwin Wesselius /'What you would like to be done to you, do that to the other....'/ |
|
|||
|
Aschwin Wesselius Ã*rta:
> Richard S. Crawford wrote: >> Hi, everyone. >> >> This one's been driving me bonkers for an hour now. Anyone have any idea >> why require_once would be dying silently in the script below? >> >> ------------------------------------ >> >> $CFG->dirroot = "/home/rcrawford/public_html/tanktrunk/tanktrunk"; >> $CFG->dataroot = $CFG->dirroot.'/moodledata'; >> >> require_once("$CFG->dirroot/lib/setup.php"); >> > > Hi, > > It reads as if $CFG is an object and ->dirroot is not a public property > of that object. So, I don't know what $CFG is, but I think the problem > lays there. if that property is not public but protected or private it would throw a fatal error. > > Also, OOP is nice and all (not to start a thread about OOP again), but > putting your config into an object seems a bit overdo to me. > I think you know I don't agree with that, but I too don't want to start this over ;) greets, Zoltán Németh |
|
|||
|
>the above won't work, as the parser will try to interpret $CFG and
put it in the string first, In that case, $CFG is either null, or it is indeed an object. If it is a standard object, which I it appears to be, then a fatal error will be thrown because there is no __tostring() function. If it's null, then require_once is referencing a directory beginning with '->', again, there *should* be an error. Anyway.. I've seen $obj->property used many times in double quotes, and never had a problem with that working. Personally though, I always use the curly braces though because it highlights better in VIM :p >Also, OOP is nice and all (not to start a thread about OOP again), but putting your config into an object seems a bit overdo to me. Me too!! (not to continue the unstarted OOP discussion) It's a practice I've seen used more than once. I think people find that syntax attractive. |
|
|||
|
Greg Bowser Ã*rta:
>> the above won't work, as the parser will try to interpret $CFG and > put it in the string first, > > In that case, $CFG is either null, or it is indeed an object. If it is > a standard object, which I it appears to be, then a fatal error will > be thrown because there is no __tostring() function. If it's null, > then require_once is referencing a directory beginning with '->', > again, there *should* be an error. Anyway.. > > I've seen $obj->property used many times in double quotes, and never > had a problem with that working. Personally though, I always use the > curly braces though because it highlights better in VIM :p I stand corrected, I just tried putting an object property into double quotes and it works greets, Zoltán Németh > >> Also, OOP is nice and all (not to start a thread about OOP again), > but putting your config into an object seems a bit overdo to me. > > Me too!! (not to continue the unstarted OOP discussion) It's a > practice I've seen used more than once. I think people find that > syntax attractive. > |