PHP函数有帮助

1 php arguments function

我很抱歉问这个问题,但我不擅长php(初学者).你能解释一下$ arg在这段代码中的含义吗?(它来自drupal模块之一)

function node_add_review_load($arg) {
  global $user;
  $add_review = FALSE;
  $current_node = node_load($arg);
  $type =$current_node->type;
  $axes_count = db_result(db_query("SELECT COUNT(*) FROM {nodereview_axes} WHERE node_type='%s'", $type));
    if (variable_get('nodereview_use_' . $type, 0) && $axes_count) {
      $add_review = db_result(db_query("SELECT n.nid FROM {node} n INNER JOIN {nodereview} nr ON n.nid=nr.nid WHERE uid=%d AND reviewed_nid=%d", $user->uid, $arg));
    }
    return $add_review ? FALSE : $arg;
 }
Run Code Online (Sandbox Code Playgroud)

谢谢.

小智 5

http://nl.php.net/manual/en/functions.arguments.php

当程序员使用node_add_review_load()时,他可以传递可以在函数中使用的参数.

如果参数$ arg不同,则该函数返回另一个值.

所以程序员可以这样做:

node_add_review_load("my argument");

//and the php automatically does:

$arg = "my argument";

//before executing the rest of the function.
Run Code Online (Sandbox Code Playgroud)