Le 2012-04-02 18:39, Ammar Yasir a écrit :
Hi, Can we have more clarity on improving reference to global variables. Is the following snippet an example of the same where? (From tbl_select.php, $_POST parameters are referenced through $GLOBALS) $post_params = array( 'ajax_request', 'collations', 'db', 'distinct', 'fields', 'func', 'max_number_of_fields', 'names', 'order', 'orderField', 'param', 'session_max_rows', 'table', 'types', 'where', ); foreach ($post_params as $one_post_param) { if (isset($_POST[$one_post_param])) { $GLOBALS[$one_post_param] = $_POST[$one_post_param]; } }
Ammar, this snippet is code added recently, to be able to remove the grab_globals.lib.php library.
tbl_select.php uses globals instead of directly referencing $_POST['foo'] so this snippet was a way to keep the script working until better refactoring.
However, many scripts are using other global variables as a way to communicate between them or between functions, and we should try to minimize this behavior.