php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #1853 function pointers on class members don't work
Submitted: 1999-07-23 17:42 UTC Modified: 1999-08-07 12:12 UTC
From: christophe dot massiot at mail dot dotcom dot fr Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0 Beta 1 OS: Debian GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: christophe dot massiot at mail dot dotcom dot fr
New email:
PHP Version: OS:

 

 [1999-07-23 17:42 UTC] christophe dot massiot at mail dot dotcom dot fr
The following script doesn't work in PHP4 :

<?
class titi {
function toto() { echo "meuuh"; }

function  main() {
  $var = "\$this->toto";
  $var();
}
}
$titi = new titi;
$titi->main();
?>

Notice that it doesn't work in PHP3 either, so it is not a bug report, rather a feature request.

It doesn't make sense in PHP3, but if you intend to push OO features in PHP4, function pointers might be pretty useful.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-07 12:12 UTC] zeev at cvs dot php dot net
They do, you're just using the wrong notation.  The function name
does not include $this - $this is only where the function is
searched.

This is the notation you should use:

$var = "toto";
$this->$var()
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 07:00:01 2026 UTC