diff --git a/examples/ctype/main.php b/examples/ctype/main.php new file mode 100644 index 00000000..6c4f92b4 --- /dev/null +++ b/examples/ctype/main.php @@ -0,0 +1,23 @@ + 127) { + throw new InvalidArgumentException('参数必须是0-127之间的整数'); + } + + // 使用chr()将ASCII码转换为字符,然后用ctype_space检测 + $char = chr($code); + return ctype_space($char); +} + +function main() +{ + $list = [9, 10, 12, 13, 32]; + foreach ($list as $code) { + if (isAsciiWhitespace($code)) { + echo "The ASCII code $code is a whitespace character.\n"; + } else { + echo "The ASCII code $code is not a whitespace character.\n"; + } + } +} \ No newline at end of file diff --git a/examples/project/ext.cc b/examples/project/ext.cc index 71df61d0..f067cb98 100644 --- a/examples/project/ext.cc +++ b/examples/project/ext.cc @@ -1,13 +1,12 @@ #include #include -#include "phpx_func.h" using namespace php; Int php_fn_test(Int a, Int b) { auto c = a + b; - var_dump(c); - var_dump(php_uname()); + call("var_dump", {c}); + call("var_dump", {call("php_uname")}); return c; } @@ -21,4 +20,4 @@ void php_foo____construct(php::Object& this_, php::Int value) { php::Int php_foo__bar(php::Object &this_, php::Int a, php::Int b) { std::cout << "hashCode: " << prop_base.str()->h << "\n"; return this_.getProperty(prop_base).toInt() + a + b; -} \ No newline at end of file +}