From 09ea347c1129f2c1353593db2c288926f801f19c Mon Sep 17 00:00:00 2001 From: rango Date: Thu, 30 Apr 2026 10:46:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(win32-hello):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=AD=E5=9B=BD=E6=97=B6=E5=8C=BA=E6=94=AF=E6=8C=81=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=80=E4=BD=B3=E5=AE=9E=E8=B7=B5=E6=8C=87?= =?UTF-8?q?=E5=8D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 hello-win.php 中添加 date_default_timezone_set('Asia/Shanghai') - 在 main.php 中添加 date_default_timezone_set('Asia/Shanghai') - 在 CHINESE_SUPPORT_GUIDE.md 中添加时区设置说明 - 更新最佳实践列表,添加时区设置建议 - 更新 .gitignore 添加 *.obj 文件忽略规则 --- .gitignore | 3 ++- examples/win32-hello/CHINESE_SUPPORT_GUIDE.md | 12 ++++++++---- examples/win32-hello/hello-win.php | 3 +++ examples/win32-hello/main.php | 3 +++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a41bb9db..0d1b6e38 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ /.php-cs-fixer.cache *.o *.dll -*.exe \ No newline at end of file +*.exe +*.obj \ No newline at end of file diff --git a/examples/win32-hello/CHINESE_SUPPORT_GUIDE.md b/examples/win32-hello/CHINESE_SUPPORT_GUIDE.md index ec620c6f..d4899491 100644 --- a/examples/win32-hello/CHINESE_SUPPORT_GUIDE.md +++ b/examples/win32-hello/CHINESE_SUPPORT_GUIDE.md @@ -92,6 +92,9 @@ function main() exec('chcp 65001 > nul 2>&1'); } + // 设置时区为中国(UTC+8) + date_default_timezone_set('Asia/Shanghai'); + echo "========================================\n"; echo " Win32 Hello World 程序\n"; echo "========================================\n\n"; @@ -189,10 +192,11 @@ php bin\compiler.php examples\win32-hello\project.yml ## 最佳实践 1. ✅ **始终在程序开始时设置 UTF-8** -2. ✅ **Windows API 使用宽字符版本(W 后缀)** -3. ✅ **UTF-8 ↔ UTF-16 转换后记得释放内存** -4. ✅ **源文件保存为 UTF-8 编码(无 BOM)** -5. ❌ **避免混用 ANSI 和 Unicode API** +2. ✅ **设置正确的时区**(`date_default_timezone_set('Asia/Shanghai')`) +3. ✅ **Windows API 使用宽字符版本**(W 后缀) +4. ✅ **UTF-8 ↔ UTF-16 转换后记得释放内存** +5. ✅ **源文件保存为 UTF-8 编码(无 BOM)** +6. ❌ **避免混用 ANSI 和 Unicode API** ## 参考资源 diff --git a/examples/win32-hello/hello-win.php b/examples/win32-hello/hello-win.php index 1c4ff4dc..c7fda024 100644 --- a/examples/win32-hello/hello-win.php +++ b/examples/win32-hello/hello-win.php @@ -14,6 +14,9 @@ function main() exec('chcp 65001 > nul 2>&1'); } + // Set timezone to China (UTC+8) + date_default_timezone_set('Asia/Shanghai'); + echo "========================================\n"; echo " Win32 Hello World 程序\n"; echo "========================================\n\n"; diff --git a/examples/win32-hello/main.php b/examples/win32-hello/main.php index 1417d0ed..4488cda3 100644 --- a/examples/win32-hello/main.php +++ b/examples/win32-hello/main.php @@ -53,6 +53,9 @@ function main() exec('chcp 65001 > nul 2>&1'); } + // Set timezone to China (UTC+8) + date_default_timezone_set('Asia/Shanghai'); + // Show a simple message box $result = MessageBox(0, "Hello from PHP Compiler!\n\n这是一个使用 PHPX 编译器创建的 Windows 程序。", "Hello World", 0);