how can i get value from inside of function?

前端 未结 4 1224
感情败类
感情败类 2021-01-23 02:35

Is it possible to get those values inside of function and use those outside of function here is my code:



        
4条回答
  •  鱼传尺愫
    2021-01-23 02:59

    1. Your can use global scope. I.e.

      $s = 1;
      function eee()
      {
       global $s;
       $s++;
      }
      echo $s;
      
    2. Your can got var/return var... if your need return more that 1 value - use array

      function eee( $s)
      {
        return $s++;
      }
      eee($s=1);
      echo $s;
      

    Prefer 2'd. Cause global scope operationing - may cause problems, when app become's large.

提交回复
热议问题