Scenario: We are in the process of converting an application from PHP 4 to PHP 5. The application needs to be able to work on PHP 4 f或a little while, which means no PHP 5 specific elements can be used, yet. We are simply trying to make sure the application works on both platforms.
应用程序中有许多条件都像这样:
if ($variable) { // do something }
其中一些变数最终完全没有定义,我们正在试图减少误差数量(其中很多是误差)。
为了解决这些错误, 我们正在多个领域添加检查 :
if (!isset($variable)) $variable = "";
或
if (!empty($variable)) { // do something }
Question: Does anyone know of a simpler approach to fixing these errors. The problem is that these variables are being used across files (via includes) and defining the variable may change the logical flow in that file if its doing a check like (if (!isset($variable)) { // do something }).
The point of this question is to reduce errors and time consumption of tracking each individual use of these variables. Currently, we are having to either examine thoroughly what the variable is doing (which may take a good chunk of time), 或we are doing a "fire and forget" / hope-its-fixed method of correcting.
-- Edit -- Does anyone know of a program like cppcheck f或php that could somehow reference these variables 或create some kind of chaining that could find errors and link possible references? (I hope that makes sense.)