1.0 KiB
1.0 KiB
Coding Rules for HOSxP Web Service
- PHP 8.1 Strict Types: This project runs on PHP 8.1+. Functions like
substr,explode, andcountwill throw Fatal Errors (TypeError) if passednull. Always check fornullor provide fallbacks (e.g.,$var ?? '') when dealing with database fields that might be NULL (likenexttimeinoapp). - MySQLi Report Mode: The codebase relies on legacy behavior where
mysqli_queryreturnsfalseon failure, rather than throwing Exceptions. Ensuremysqli_report(MYSQLI_REPORT_OFF);is maintained, and do NOT enableMYSQLI_REPORT_STRICT, as it will cause cascading 500 errors across the application. - Variable Scope & Require_Once: Never place
require_oncefor configuration files (likedb.php) inside functions or conditional local scopes unless returning the variables. Doing so traps the variables (like$conn1) in the local scope, preventing them from being accessible in the global scope during subsequent includes, leading toUndefined variableerrors.