note 57141 deleted from functions.arguments by cmb

From: Date: Sun, 10 Nov 2019 13:17:10 +0000
Subject: note 57141 deleted from functions.arguments by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213021@lists.php.net to get a copy of this message
Note Submitter: grinslives13 at hotmail dot com~=s/i/ee/g ---- Given that we have two coding styles: # # Code (A) # funtion foo_a (&$var) { $var *= 2; return $var; } foo_a($a); # # Code (B) # function foo_b ($var) { $var *= 2; return $var; } foo_b(&$a); I personally wouldn't recommend (B) - I think it strange why php would support such a convention as it would have violated foo_b's design - its use would not do justice to its function prototype. And thinking about such use, I might have to think about copying all variables instead of working directly on them... Coding that respects function prototypes strictly would, I believe, result in code that is more intuitive to read. Of course, in php <=4, not being able to use default values with references, we can't do this that we can do in C: # # optional return-value parameters # int foo_c (int var, int *ret) { var *= 2; if (ret) *ret = var; return var; } foo_c(2, NULL); Of course, since variables are "free" anyway, we can always get away with it by using dummy variables... zlel

« previous php.notes (#213021) next »