最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

loop - How set a while with a function

programmeradmin1浏览0评论

i have a simple function and i need that while it execute my function it set a variable to true, otherwise false. the execution would be my condition.

while run this func 

function need() {                                           
        $updates = get_point();
        echo  $updates['selector']; 
        echo 'done';
        }

i need that my $set is true, otherwise false. how can i put the func inside?

i have a simple function and i need that while it execute my function it set a variable to true, otherwise false. the execution would be my condition.

while run this func 

function need() {                                           
        $updates = get_point();
        echo  $updates['selector']; 
        echo 'done';
        }

i need that my $set is true, otherwise false. how can i put the func inside?

Share Improve this question asked Feb 5, 2020 at 16:13 DevBeppeDevBeppe 477 bronze badges 6
  • This sounds like a pure PHP question, it would be better on stack overflow. What are you trying to do that requires this? What the problem this solves – Tom J Nowell Commented Feb 5, 2020 at 16:42
  • This question lacks of explanation. $set even exist in your code. Could explain better? – Cadu De Castro Alves Commented Feb 5, 2020 at 16:46
  • i have the define('DISALLOW_FILE_MODS', $test); and i want change while my function run – DevBeppe Commented Feb 5, 2020 at 17:03
  • you can't undefine something once it's been defined – Tom J Nowell Commented Feb 5, 2020 at 17:19
  • 1 Your code is still unclear, but if for some reason you want to apply / not apply the DISALLOW_FILE_MODS directive you sholud not define it as constant ( once defined cannot be undefined as per @TomJNowell comment above) but try to use instead the correspondent filter developer.wordpress/reference/hooks/file_mod_allowed – Andrea Somovigo Commented Feb 5, 2020 at 17:28
 |  Show 1 more comment

1 Answer 1

Reset to default 0

a. from the return

function dosome(){ return true; }
OR
function dosome( param = true ){ return param; }

var = dosome();
while ( var ){ need(); }

b. while loop from fixed param TRUE

function need( $param = true) {

  while ( param ){
    $updates = get_point();
    echo  $updates['selector']; 
    echo 'done';
  }                                           

}
need();

c. while loop from fixed param FALSE

function need( $param = false) {

  while ( param ){
    $updates = get_point();
    echo  $updates['selector']; 
    echo 'done';
  }                                           

}
var = true;
need( var );
发布评论

评论列表(0)

  1. 暂无评论