Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

javascript - 如何将参数传递给函数(How to pass parameters to a function)

This is my addColumn function, to which I want to pass these two parameters, $result and $filter_id .(这是我的addColumn函数,我要将这两个参数$result$filter_id传递给该函数。)

->addColumn('check_field', function ($result,$filter_fld) { $check_fields = $filter_fld; $check_field_arr = $this->createAarrayChackList($check_fields); $status = in_array($result->id, $check_field_arr)==true ? 'checked' :''; return '<input type="checkbox" class="chk itemName form-check-input" id="seasel" value="$data->id" name="origin_port" onclick="get_value_to_hidden_field();" '.$status.'>'; }) How can i pass the two parameters?(如何传递两个参数?)   ask by vivek kalanka translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are passing parameters to a function that be named closure .(您正在将参数传递给名为closure的函数。)

A closure is a function that is evaluated in its own environment, which has one or more bound variables that can be accessed when the function is called.(闭包是在其自己的环境中求值的函数,该函数具有一个或多个绑定变量,调用该函数时可以访问它们。) The use() keyword let's you import variables from outside the function environment , inside the function.(use()关键字使您可以从函数环境外部,函数内部导入变量 。) ->addColumn('check_field', function () use ($result, $filter_fld) { ... })

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...