|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-05-19 09:46 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 12:00:01 2025 UTC |
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 _.