当前位置: 首页>>代码示例>>PHP>>正文


PHP func_num_args函数代码示例

本文整理汇总了PHP中func_num_args函数的典型用法代码示例。如果您正苦于以下问题:PHP func_num_args函数的具体用法?PHP func_num_args怎么用?PHP func_num_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了func_num_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: zip

/**
 * Zips two or more sequences
 *
 * @param array|\Traversable $sequence1
 * @param array|\Traversable $sequence2
 * @return array
 */
function zip($sequence1, $sequence2)
{
    $lists = func_get_args();
    $count = func_num_args();
    for ($j = 0; $j < $count; ++$j) {
        args\expects(args\traversable, $lists[$j], $j + 1);
        $lists[$j] = ds\traversableToArray($lists[$j]);
        if (!ds\isList($lists[$j])) {
            $lists[$j] = array_values($lists[$j]);
        }
    }
    $i = 0;
    $result = array();
    do {
        $zipped = array();
        for ($j = 0; $j < $count; ++$j) {
            if (!isset($lists[$j][$i]) && !array_key_exists($i, $lists[$j])) {
                break 2;
            }
            $zipped[] = $lists[$j][$i];
        }
        $result[] = $zipped;
        ++$i;
    } while (true);
    return $result;
}
开发者ID:rakesh-mohanta,项目名称:Nspl,代码行数:33,代码来源:a.php

示例2: __construct

 /**
  * Default constructor
  * @param value some value
  */
 function __construct()
 {
     $args = func_get_args();
     if (func_num_args() == 1) {
         $this->init($args[0]);
     }
 }
开发者ID:renduples,项目名称:alibtob,代码行数:11,代码来源:Albumtype.php

示例3: index

 /**
  * Carrega a página "/views/user-register/index.php"
  */
 public function index()
 {
     // Page title
     $this->title = 'User Register';
     // Verifica se o usuário está logado
     if (!$this->logged_in) {
         // Se não; garante o logout
         $this->logout();
         // Redireciona para a página de login
         $this->goto_login();
         // Garante que o script não vai passar daqui
         return;
     }
     // Verifica se o usuário tem a permissão para acessar essa página
     if (!$this->check_permissions($this->permission_required, $this->userdata['user_permissions'])) {
         // Exibe uma mensagem
         echo 'Você não tem permissões para acessar essa página.';
         // Finaliza aqui
         return;
     }
     // Parametros da função
     $parametros = func_num_args() >= 1 ? func_get_arg(0) : array();
     // Carrega o modelo para este view
     $modelo = $this->load_model('user-register/user-register-model');
     /** Carrega os arquivos do view **/
     // /views/_includes/header.php
     require ABSPATH . '/views/_includes/header.php';
     // /views/_includes/menu.php
     require ABSPATH . '/views/_includes/menu.php';
     // /views/user-register/index.php
     require ABSPATH . '/views/user-register/user-register-view.php';
     // /views/_includes/footer.php
     require ABSPATH . '/views/_includes/footer.php';
 }
开发者ID:Anpix,项目名称:TutsupMVC,代码行数:37,代码来源:user-register-controller.php

示例4: chr

 /**
  * Returns a specific character in UTF-8.
  * @param  int     codepoint
  * @return string
  */
 public static function chr($code)
 {
     if (func_num_args() > 1 && strcasecmp(func_get_arg(1), 'UTF-8')) {
         trigger_error(__METHOD__ . ' supports only UTF-8 encoding.', E_USER_DEPRECATED);
     }
     return iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code));
 }
开发者ID:rostenkowski,项目名称:nette,代码行数:12,代码来源:Strings.php

示例5: getUrl

 /**
  * Set asset url path
  *
  * @param string     $path
  * @param null       $packageName
  * @param null       $version
  * @param bool|false $absolute
  * @param bool|false $ignorePrefix
  *
  * @return string
  */
 public function getUrl($path, $packageName = null, $version = null)
 {
     // Dirty hack to work around strict notices with parent::getUrl
     $absolute = $ignorePrefix = false;
     if (func_num_args() > 3) {
         $args = func_get_args();
         $absolute = $args[3];
         if (isset($args[4])) {
             $ignorePrefix = $args[4];
         }
     }
     // if we have http in the url it is absolute and we can just return it
     if (strpos($path, 'http') === 0) {
         return $path;
     }
     // otherwise build the complete path
     if (!$ignorePrefix) {
         $assetPrefix = $this->getAssetPrefix(strpos($path, '/') !== 0);
         $path = $assetPrefix . $path;
     }
     $url = parent::getUrl($path, $packageName, $version);
     if ($absolute) {
         $url = $this->getBaseUrl() . $url;
     }
     return $url;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:37,代码来源:AssetsHelper.php

示例6: dump

 public function dump(\Twig_Environment $env, $context)
 {
     if (!$env->isDebug()) {
         return;
     }
     if (2 === func_num_args()) {
         $vars = array();
         foreach ($context as $key => $value) {
             if (!$value instanceof \Twig_Template) {
                 $vars[$key] = $value;
             }
         }
         $vars = array($vars);
     } else {
         $vars = func_get_args();
         unset($vars[0], $vars[1]);
     }
     $dump = fopen('php://memory', 'r+b');
     $dumper = new HtmlDumper($dump);
     foreach ($vars as $value) {
         $dumper->dump($this->cloner->cloneVar($value));
     }
     rewind($dump);
     return stream_get_contents($dump);
 }
开发者ID:hannesvdvreken,项目名称:TwigBridge,代码行数:25,代码来源:Dump.php

示例7: add_user

/**
 * Creates a new user from the "Users" form using $_POST information.
 *
 * It seems that the first half is for backwards compatibility, but only
 * has the ability to alter the user's role. WordPress core seems to
 * use this function only in the second way, running edit_user() with
 * no id so as to create a new user.
 *
 * @since 2.0
 *
 * @param int $user_id Optional. User ID.
 * @return null|WP_Error|int Null when adding user, WP_Error or User ID integer when no parameters.
 */
function add_user()
{
    if (func_num_args()) {
        // The hackiest hack that ever did hack
        global $current_user, $wp_roles;
        $user_id = (int) func_get_arg(0);
        if (isset($_POST['role'])) {
            $new_role = sanitize_text_field($_POST['role']);
            // Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
            if ($user_id != $current_user->id || $wp_roles->role_objects[$new_role]->has_cap('edit_users')) {
                // If the new role isn't editable by the logged-in user die with error
                $editable_roles = get_editable_roles();
                if (empty($editable_roles[$new_role])) {
                    wp_die(__('You can&#8217;t give users that role.'));
                }
                $user = new WP_User($user_id);
                $user->set_role($new_role);
            }
        }
    } else {
        add_action('user_register', 'add_user');
        // See above
        return edit_user();
    }
}
开发者ID:laiello,项目名称:cartonbank,代码行数:38,代码来源:user.php

示例8: setcookie

 /**
  * Set the browser cookie
  * @param string $name The name of the cookie.
  * @param string $value The value to be stored in the cookie.
  * @param int|null $expire Unix timestamp (in seconds) when the cookie should expire.
  *        0 (the default) causes it to expire $wgCookieExpiration seconds from now.
  *        null causes it to be a session cookie.
  * @param array $options Assoc of additional cookie options:
  *     prefix: string, name prefix ($wgCookiePrefix)
  *     domain: string, cookie domain ($wgCookieDomain)
  *     path: string, cookie path ($wgCookiePath)
  *     secure: bool, secure attribute ($wgCookieSecure)
  *     httpOnly: bool, httpOnly attribute ($wgCookieHttpOnly)
  *     raw: bool, if true uses PHP's setrawcookie() instead of setcookie()
  *   For backwards compatibility, if $options is not an array then it and
  *   the following two parameters will be interpreted as values for
  *   'prefix', 'domain', and 'secure'
  * @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options
  */
 public function setcookie($name, $value, $expire = 0, $options = array())
 {
     global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
     global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly;
     if (!is_array($options)) {
         // Backwards compatibility
         $options = array('prefix' => $options);
         if (func_num_args() >= 5) {
             $options['domain'] = func_get_arg(4);
         }
         if (func_num_args() >= 6) {
             $options['secure'] = func_get_arg(5);
         }
     }
     $options = array_filter($options, function ($a) {
         return $a !== null;
     }) + array('prefix' => $wgCookiePrefix, 'domain' => $wgCookieDomain, 'path' => $wgCookiePath, 'secure' => $wgCookieSecure, 'httpOnly' => $wgCookieHttpOnly, 'raw' => false);
     if ($expire === null) {
         $expire = 0;
         // Session cookie
     } elseif ($expire == 0 && $wgCookieExpiration != 0) {
         $expire = time() + $wgCookieExpiration;
     }
     $func = $options['raw'] ? 'setrawcookie' : 'setcookie';
     if (Hooks::run('WebResponseSetCookie', array(&$name, &$value, &$expire, $options))) {
         wfDebugLog('cookie', $func . ': "' . implode('", "', array($options['prefix'] . $name, $value, $expire, $options['path'], $options['domain'], $options['secure'], $options['httpOnly'])) . '"');
         call_user_func($func, $options['prefix'] . $name, $value, $expire, $options['path'], $options['domain'], $options['secure'], $options['httpOnly']);
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:48,代码来源:WebResponse.php

示例9: dequeue

 /**
  * Dequeues one or several values from the beginning of the Queue
  *
  * When called without argument, returns a single value, else returns an array.
  * If there is not anough elements in the queue, all the elements are returned
  * without raising any error.
  *
  * @param int $quantity
  *
  * @return mixed
  */
 public function dequeue($quantity = 1)
 {
     if (!func_num_args()) {
         return array_pop($this->elements);
     }
     return array_splice($this->elements, max(0, count($this->elements) - $quantity), $quantity, []);
 }
开发者ID:kgodet,项目名称:Aldente,代码行数:18,代码来源:Queue.php

示例10: parse

 public static function parse($parser)
 {
     $parser->disableCache();
     $title = $parser->getTitle()->getText();
     $titleArray = explode(':', $title);
     $ontAbbr = $titleArray[0];
     $termID = str_replace(' ', '_', $titleArray[1]);
     $ontology = new OntologyData($ontAbbr);
     $term = $ontology->parseTermByID($termID);
     $params = array();
     for ($i = 2; $i < func_num_args(); $i++) {
         $params[] = func_get_arg($i);
     }
     list($options, $valids, $invalids) = self::extractSupClass($params, $ontology);
     $pathType = $GLOBALS['okwHierarchyConfig']['pathType'];
     $supClasses = array();
     if (!empty($valids)) {
         foreach ($valids as $index => $value) {
             $supClasses[] = $value['iri'];
             $hierarchy = $ontology->parseTermHierarchy($term, $pathType, $value['iri']);
             if ($value['iri'] == $GLOBALS['okwRDFConfig']['Thing']) {
                 $GLOBALS['okwCache']['hierarchy'][$index] = $hierarchy;
             } else {
                 foreach ($hierarchy as $path) {
                     if (!empty($path['path'])) {
                         $GLOBALS['okwCache']['hierarchy'][$index] = $hierarchy;
                     }
                 }
             }
         }
     }
     wfDebugLog('OntoKiWi', sprintf('OKW\\Parser\\HierarchyParser: parsed hierarchy {%s} for [[%s]]', join(';', $supClasses), $title));
     wfDebugLog('OntoKiWi', '[caches] OKW\\Parser\\HierarchyParser: hierarchy');
     return array('', 'noparse' => true);
 }
开发者ID:e4ong1031,项目名称:Ontokiwi,代码行数:35,代码来源:HierarchyParser.php

示例11: __new__

 protected final function __new__()
 {
     parent::__new__(func_num_args() > 0 ? func_get_arg(0) : null);
     $this->o('Template')->cp($this->vars);
     $this->request_url = parent::current_url();
     $this->request_query = parent::query_string() == null ? null : '?' . parent::query_string();
 }
开发者ID:satully,项目名称:dev_socialapp,代码行数:7,代码来源:Flow.php

示例12: checkRights

 public static function checkRights()
 {
     //print_r(func_get_args());
     if (func_num_args() == 0) {
         return true;
     }
     //print_r($_SESSION['user']);
     if (empty($_SESSION['user'])) {
         return false;
     }
     $right = $_SESSION['user']['type'];
     //echo $right;
     if ($right == USR_ADMIN) {
         return true;
     }
     $right_groups = func_get_args();
     // print_r($right_groups);
     if (empty($right_groups)) {
         return false;
     }
     /*
             foreach($right_groups as $group){
        if(is_array($group))
        if($group==$right)
            return true;
             }
             return false;     
     */
     return UserRights::checkRight($right_groups, $right);
 }
开发者ID:estrom85,项目名称:sample-codes,代码行数:30,代码来源:UserRights.php

示例13: format

 /**
  * Creates an exception using a formatted message.
  *
  * @param string $format    The message format.
  * @param mixed  $value,... A value.
  *
  * @return static The exception.
  */
 public static function format($format, $value = null)
 {
     if (1 < func_num_args()) {
         $format = vsprintf($format, array_slice(func_get_args(), 1));
     }
     return new static($format);
 }
开发者ID:ticketscript,项目名称:php-wise,代码行数:15,代码来源:AbstractException.php

示例14: onlyForAjaxRequests

 /**
  * @param  bool|null $onlyForAjaxRequests
  * @return null|bool
  */
 public function onlyForAjaxRequests($onlyForAjaxRequests = null)
 {
     if (func_num_args() == 0) {
         return $this->onlyForAjaxRequests;
     }
     $this->onlyForAjaxRequests = (bool) $onlyForAjaxRequests;
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:11,代码来源:JsonResponseHandler.php

示例15: log

 /**
  * Default logger method logging to STDOUT.
  * This is the default/reference implementation of a logger.
  * This method will write the message value to STDOUT (screen) unless
  * you have changed the mode of operation to C_LOGGER_ARRAY.
  *
  * @param $message (optional) message to log (might also be data or output)
  *
  * @return void
  */
 public function log()
 {
     if (func_num_args() < 1) {
         return;
     }
     foreach (func_get_args() as $argument) {
         if (is_array($argument)) {
             $log = print_r($argument, TRUE);
             if ($this->mode === self::C_LOGGER_ECHO) {
                 echo $log;
             } else {
                 $this->logs[] = $log;
             }
         } else {
             if ($this->mode === self::C_LOGGER_ECHO) {
                 echo $argument;
             } else {
                 $this->logs[] = $argument;
             }
         }
         if ($this->mode === self::C_LOGGER_ECHO) {
             echo "<br>\n";
         }
     }
 }
开发者ID:nekrasovdmytro,项目名称:redbean,代码行数:35,代码来源:RDefault.php


注:本文中的func_num_args函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。