[PHP] Call to undefined function problem
I'm doing the following: test.php - -- functions.php - "; function setNoCacheHeaders( ) { static $headersNotSet = TRUE; if ( $headersNotSet ) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 $headersNotSet = FALSE; } } echo "here 2"; // a few more functions here } My output is here 1 here 2 Fatal error: Call to undefined function: setnocacheheaders() in $DOCUMENT_ROOT/test.php on line 16 Can someone explain? I found something similar in the archives but no answer was given. This exact code worked under php3. The only changes in the files were files ending in php3 were changed to end php. I also had 2 classes that I was using that had initializers in the variable declaration. I moved the initialization to constructors. Note that on some clients the request goes through w/o errors. This is intermittent but consistent on a per client basis. - doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Call to undefined function problem
Further information: The page is navigated to via a previous page using a "Location: /test.php" header. The problem occurs when I first navigate to the page. If I then do a refresh from the browser, the problem disappears. I also did further testing where I put the following type of code between the requires (a unique number for each statement): if (function_exists("setNoCacheHeaders")) { echo "exists 1"; } else { echo "does not exist 1"; } In the broken scenario, the function never exists. In the working scenario it is always there. I also neglected to say that I was switching from php3.0.14 to php4.0.6. "Doug Farmer" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I'm doing the following: > > test.php - > require("functions.php"); > require(""); // several other requires here > > setNoCacheHeaders(); // this is line 16 > > // other stuff here > ?> > > -- functions.php - > > if (!define("__FUNCTIONS__") ) > { > define( "__FUNCTIONS__", 1, 1 ); > > // a bunch of other defines here > echo "here 1"; > function setNoCacheHeaders( ) { > static $headersNotSet = TRUE; > > if ( $headersNotSet ) { > header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Date in the > past > header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // > always modified > header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 > header("Pragma: no-cache"); // HTTP/1.0 > $headersNotSet = FALSE; > } > } > echo "here 2"; > > // a few more functions here > > } > > > > My output is > here 1 > here 2 > > Fatal error: Call to undefined function: setnocacheheaders() in > $DOCUMENT_ROOT/test.php on line 16 > > Can someone explain? I found something similar in the archives but no > answer was given. This exact code worked under php3. The only changes in > the files were files ending in php3 were changed to end php. I also had 2 > classes that I was using that had initializers in the variable declaration. > I moved the initialization to constructors. > > Note that on some clients the request goes through w/o errors. This is > intermittent but consistent on a per client basis. > > - doug > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Call to undefined function problem
Thanks. I ran some further tests and came to the same conclusion. My test showed that the constant was defined even though in theory it should be a new request. Since this is a production system, I don't want to go with a release candidate. I'm going to do a switchover to "include_once". "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Try the current 4.0.7 release candidates. There were some define() > related issues in prior versions. Also, in PHP 4 you don't need those > defines to protect from multiple inclusion. You can simply use > include_once > > -Rasmus > > On Mon, 10 Sep 2001, Doug Farmer wrote: > > > > > I'm doing the following: > > > > test.php - > > > require("functions.php"); > > require(""); // several other requires here > > > > setNoCacheHeaders(); // this is line 16 > > > > // other stuff here > > ?> > > > > -- functions.php - > > > > > if (!define("__FUNCTIONS__") ) > > { > > define( "__FUNCTIONS__", 1, 1 ); > > > > // a bunch of other defines here > > echo "here 1"; > > function setNoCacheHeaders( ) { > > static $headersNotSet = TRUE; > > > > if ( $headersNotSet ) { > > header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Date in the > > past > > header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // > > always modified > > header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 > > header("Pragma: no-cache"); // HTTP/1.0 > > $headersNotSet = FALSE; > > } > > } > > echo "here 2"; > > > > // a few more functions here > > > > } > > > > > > > > My output is > > here 1 > > here 2 > > > > Fatal error: Call to undefined function: setnocacheheaders() in > > $DOCUMENT_ROOT/test.php on line 16 > > > > Can someone explain? I found something similar in the archives but no > > answer was given. This exact code worked under php3. The only changes in > > the files were files ending in php3 were changed to end php. I also had 2 > > classes that I was using that had initializers in the variable declaration. > > I moved the initialization to constructors. > > > > Note that on some clients the request goes through w/o errors. This is > > intermittent but consistent on a per client basis. > > > > - doug > > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Call to undefined function problem
Typo in my explanation. I had "defined" in my code. Nice catch though. However, I'm running into more define issues. When I get to a file through a redirect via header("Location: /newfile.php"), my defines are existing as tested by "defined" but the values are all corrupt. However, if I then refresh the page, the value is good. Anyone else seen this in php-4.0.6? Can someone explain to me what is fixed for defines in the 4.0.7 candidate? Andrey Hristov <[EMAIL PROTECTED]> wrote in message 01ce01c13a93$a4fd6d00$0b01a8c0@ANDreY">news:01ce01c13a93$a4fd6d00$0b01a8c0@ANDreY... > if (!define("__FUNCTIONS__") ) > must be: > > if (!defined("__FUNCTIONS__") ) > > > > Andrey Hristov > IcyGEN Corporation > http://www.icygen.com > BALANCED SOLUTIONS > > > - Original Message - > From: "Doug Farmer" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, September 11, 2001 6:50 AM > Subject: [PHP] Call to undefined function problem > > > > > > I'm doing the following: > > > > test.php - > > > require("functions.php"); > > require(""); // several other requires here > > > > setNoCacheHeaders(); // this is line 16 > > > > // other stuff here > > ?> > > > > -- functions.php - > > > > > if (!define("__FUNCTIONS__") ) > > { > > define( "__FUNCTIONS__", 1, 1 ); > > > > // a bunch of other defines here > > echo "here 1"; > > function setNoCacheHeaders( ) { > > static $headersNotSet = TRUE; > > > > if ( $headersNotSet ) { > > header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Date in the > > past > > header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // > > always modified > > header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 > > header("Pragma: no-cache"); // HTTP/1.0 > > $headersNotSet = FALSE; > > } > > } > > echo "here 2"; > > > > // a few more functions here > > > > } > > > > > > > > My output is > > here 1 > > here 2 > > > > Fatal error: Call to undefined function: setnocacheheaders() in > > $DOCUMENT_ROOT/test.php on line 16 > > > > Can someone explain? I found something similar in the archives but no > > answer was given. This exact code worked under php3. The only changes in > > the files were files ending in php3 were changed to end php. I also had 2 > > classes that I was using that had initializers in the variable declaration. > > I moved the initialization to constructors. > > > > Note that on some clients the request goes through w/o errors. This is > > intermittent but consistent on a per client basis. > > > > - doug > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] corrupted definitions
I have definitions (i.e. define ("a", "b");) that are being corrupted in php-4.0.6 in apache 1.3.20 on Redhat linux from Jan. 11. Anyone seen this? Any solutions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: corrupted definitions
Further info: I'm on Redhat Linux 6.2. The uname output is "Linux web2 2.2.13-0.13smp #1 SMP Tue Jan 11 13:26:01 EST 2000 i686 unknown." Also, the problem goes away if I set display_errors in php.ini to Off. Can someone explain? I'm guessing a memory overrun somewhere. Note that on another machine running Redhat Linux 6.1 with a uname output of "Linux web3 2.2.16-3smp #1 SMP Mon Jun 19 19:00:35 EDT 2000 i686 unknown", the problem does NOT occur even if display_errors in php.ini is set to On. - doug Doug Farmer <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have definitions (i.e. define ("a", "b");) that are being corrupted in > php-4.0.6 in apache 1.3.20 on Redhat linux from Jan. 11. > > Anyone seen this? Any solutions? > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] scoping: can someone explain to me if this should/should not work?
The following code seems to work in general but everyone once in a while I'm getting a segmentation fault. Can someone explain to me why this would be intermittent and/or whether or not it should work? function getDomain($serverName) { $result = $serverName; // some processing to result occurs here echo "here 3: $result"; return $result; } function test() { global $SERVER_NAME; echo "here 1"; $domain = getDomain($SERVER_NAME); echo "here 2"; } When I get a segv, I get the output: here 1 here 3: The "here 2" is not displayed. I thought that this would a return by copy and not have an issue. - doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]