|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57025 Can't use functions that begin with _
Submitted: 2006-05-18 23:51 UTC Modified: 2006-05-19 09:46 UTC
From: tech-php at sklar dot com Assigned: wez (profile)
Status: Closed Package: ffi (PECL)
PHP Version: 5.1.2 OS:
Private report: No CVE-ID: None
 [2006-05-18 23:51 UTC] tech-php at sklar dot com
I can't bind to the _getch() function in msvcrt.dll with FFI. I think this is because it begins with an underscore.

Reproduce code:
$z = new FFI("[lib='msvcrt.dll']
    int _getch();

while (($c = $z->_getch()) != ord("\r")) {
    $s .= chr($c);

print "You typed [$s]\n";


Expected result:
Something similar to this, which works fine:

$z = new FFI("[lib='msvcrt.dll']
    int getchar();

while (($c = $z->getchar()) != ord("\r")) {
    $s .= chr($c);

print "You typed [$s]\n";


Except that the characters wouldn't be echoed to the console, since that's how _getch() works

Actual result:
Fatal error: Call to undefined method FFI::_getch() in c:\getch.php on line 6

I am thinking that it is the leading underscore in _getch() because of the following code in the default case in parse_defs() in ffi_library.c:

if (isalpha(*c)) {
  while (isalnum(*c) || *c == '_') {

This seems to indicate that tokens must start with a letter but then can be alphanumeric or _.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 09:46 UTC]
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

Fixed in CVS.  A working version should show up on "soonish".
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 08 22:03:33 2022 UTC