Bug #14221 Updated: Segmentation fault when using class that accesses member functions & variables.
| From: | yohgaki@php.net | Date: | Tue, 02 Apr 2002 02:39:36 +0000 |
| Subject: | Bug #14221 Updated: Segmentation fault when using class that accesses member functions & variables. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-3783@lists.php.net to get a copy of this message | ||
ID: 14221
Updated by: yohgaki@php.net
Reported By: nickj@nickj.org
Status: Duplicate
Bug Type: Scripting Engine problem
Operating System: Linux Mandrake 7.2
PHP Version: 4.0.4pl1
New Comment:
http://bugs.php.net/bug.php?id=16265
should be reopenned. (I just did)
Previous Comments:
------------------------------------------------------------------------
[2002-04-01 19:16:29] nickj@nickj.org
This looks to have been resolved here:
http://bugs.php.net/bug.php?id=16265
If this is correct, can this report be closed?
------------------------------------------------------------------------
[2001-12-06 07:18:42] yohgaki@php.net
Make this report a duplicate of #13703
------------------------------------------------------------------------
[2001-11-26 04:01:48] nickj@nickj.org
> php doesn't call functions based on the parameters given
Ah hah! OK, that changes everything - I was thinking like C++ classes,
which, if my memory serves me correctly, know which member function to
use.
Modified code that deals with this OK:
========================================================
#!/usr/bin/php -q
<?php
error_reporting (E_ALL);
class test {
var $currentField;
function setCurrentField($field_name) {
$this->currentField = $field_name;
}
function getValue($field_name = false) {
if ($field_name === false) $field_name =
$this->currentField;
return "getValue with arg - $field_name\n";
}
}
$frm = new test;
$frm->setCurrentField("blah");
print $frm->getValue("real arg");
print $frm->getValue();
?>
========================================================
> That's an ZE problem (ie.
> method with same name should give parse error or at least some
> warning).
Agreed.
Testing this with straight functions shows that the engine does do this
for straight functions:
========================================================
#!/usr/bin/php -q
<?php
error_reporting (E_ALL);
function blah() {
print "no arg\n";
}
function blah($field) {
print "with arg, $field\n";
}
blah();
blah("test");
?>
========================================================
Output gives:
[root tmp]# ./test.php
<br>
<b>Fatal error</b>: Cannot redeclare blah() in <b>./test.php</b> on
line <b>9</b><br>
[root tmp]#
An equivalent "Cannot redeclare test class member function blah() in
test.php on line 9" would be extremely helpful and is probably called
for - I've always found the PHP syntax checking to extremely clear and
spot-on previously.
Many thanks for all your help,
Kind Regards,
Nick.
------------------------------------------------------------------------
[2001-11-26 03:05:16] mfischer@php.net
Your code is obviously bogus.
You're definig two methods with the same name. But I admit this
shouldn't be possible, derick?
Anyway, because of this the second getValue() overwrites the former and
therefore you have an infinite look; getValue calls getValue calls
getValue calls ...
That's an ZE problem (ie. method with same name should give parse error
or at least some warning).
(Correct if otherwise)
ps: php doesn't call funtions based on the parameters given
------------------------------------------------------------------------
[2001-11-26 02:46:22] derick@php.net
Can you try the latest RC from : www.php.net/~zeev/php-4.1.0RC3.tar.gz
?
Derick
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/14221
--
Edit this bug report at http://bugs.php.net/?id=14221&edit=1