|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-06-11 12:47 UTC] tsullivan at nforce dot com
/****************** From phpinfo() ******************/
'./configure' '--with-apxs=/usr/local/sbin/apxs' '--with-config-file-path=/usr/local/etc' '--enable-versioning' '--with-system-regex' '--disable-debug' '--enable-track-vars' '--without-gd' '--without-mysql' '--with-gd=/usr/local' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-zlib' '--with-imap=/usr/local' '--with-mysql=/usr/local' '--with-ldap=/usr/local' '--prefix=/usr/local' 'i386--freebsd4.3'
/*******************************************************/
The script is made up of several files. It doesn't produce a standard PHP error, rather the browser (IE5) says that the server sent an unrecognized response. The script executes fine if I comment out the line in question.
Here is the requested URI:
/*******************************************************/
<?php
require_once("TsTestBoundObject.class.php");
session_start();
if ($HTTP_GET_VARS["reset"]==1) {
session_destroy();
session_start();
}
if (!is_object($_SESSION["tester"])) {
$_SESSION["tester"]=& new TsTestBoundObject("Hello World!<br>\n");
$_SESSION["test2"]=& new TsTestBoundObject("Hello World!<br>\n");
}
echo $_SESSION["tester"]->UOID; //WORKS FINE
echo $_SESSION["test2"]->UOID; //WORKS FINE TOO
$temp = $_SESSION["tester"]; //ALL GOOD
$temp2 = $_SESSION["test2"]; //ALL GOOD
//$temp->setRelation("isParentOf", $temp2, "isChildOf");
echo $temp->content; //WORKS FINE
$temp->test("hello?", $temp2);
?>
/***************** END REQUESTED URI ********************/
The third last line (which is commented out) was what originally caused the error. That led me to create a method called test() in the same base class as setRelation() (note that object $temp belongs to a derived class of the class in which i defined test() and setRelation().
When I implemented test() like below, I get the expected results:
function test($something, &$c) {
echo $something;
echo $c->content;
}
This produced a normal result, the string I passed in the call followed by $c->content, which was set to "Hello world".
However, as soon as I changed the method to resemble the prototype of the method that was originally messed up (setRelation()), I got a very weird result:
function test($something, &$c, $somethin2="") {
echo $something;
echo $c->content;
echo $somethin2;
}
In this scenario, I called the above method like this:
$temp->test("Hello", $temp2);
Which should have produced the SAME output. Instead, it only prints out $temp2->content ("Hello World") and acts as though the $something was non-existent. Calling it with the third argument explicitly listed in the call resulted in the same thing.
This led me to the conclusion that because of the argument count mismatch combined with the interpreter's lack of knowledge about the mismatch, PHP generated some type of weird output that caused my browser to get confused.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 18:00:01 2025 UTC |
/********** ADDITION ************/ Wow, weird. First, $temp->content was set to the string "test2". Now I just called this: $temp->test("hello?", $temp2, "hello again?"); where I defined test() as: function test($something, &$c, $somethin2) { echo $something; echo $c->content; echo $somethin2; } and the output was: hello again?test2 hello again? So in this instance, the string passed in the third argument was copied to $something and $somethin2???