Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

php built-in function is return value or print the value? [closed]

$
0
0

is the built-in function return value or just print the value?

we have built-in function like str_repeat() does the value is returned or just printedwhen we implement the func should we return the value or just echo the value

like this:   function string_repate($str , $num){       $result ="";     for ($i =0 ; $i< $num ; $i++){       $result .= $str;    }     return $result;   }   echo string_repate("ahmad", 5);or:   function string_repate($str , $num){      for ($i =0 ; $i< $num ; $i++){          echo "$str";       }   }  echo string_repate("ahmad", 5);

Viewing all articles
Browse latest Browse all 210

Latest Images

Trending Articles



Latest Images