php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 + 11 = ?
Subscribe to this entry?

 
 [2006-05-18 23:51 UTC] tech-php at sklar dot com
Description:
------------
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:
---------------
<?php
$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:

<?php
$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 == '_') {
    c++;
  }

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 09:46 UTC] wez@php.net
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 pecl.php.net.

In case this was a pecl.php.net 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 pecl4win.php.net "soonish".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC