How to use return inside a recursive functions in php
问题 Here is my question I am trying to create a random bar code for my application, I want to check if that code is already in the column than generate a new number, check it again if its unique return it to the caller else generate again. I am using a recursive function for this purpose. I have added number 1,2,3,4 inside my database so every time it runs it has to show me 5,6,7,8,9 or 10. Here is my function: function generate_barcode(){ $barcode = rand(1,10); $bquery = mysql_num_rows(mysql