Program for length of a string using recursion | Function to calculate length ; if we reach at the end of the string ; Driver Code
< ? php function recLen ( & $ str , $ i ) { if ( $ i == strlen ( $ str ) ) return 0 ; else return 1 + recLen ( $ str , $ i + 1 ) ; } $ str = " GeeksforGeeks " ; echo ( recLen ( $ str , 0 ) ) ; ? >