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);