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


PHP type函数代码示例

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


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

示例1: do_method

 function do_method($a, $v = null)
 {
     $p = $this->target ? $this->target : $this;
     $args = optimize_args(func_get_args());
     /*get callback*/
     foreach ($args as $z) {
         if (ispack($z) && type($z) == 'object') {
             $cb = $z;
         }
     }
     $methods = $this->methods($p);
     if (isStr($a)) {
         if (isIn($a, $methods)) {
             $p->{$a}($v);
         } else {
             if (isset($cb)) {
                 $cb($p, array($a, $v));
             } else {
                 $p->attr($a, $v);
             }
         }
     } else {
         while (list($i, $v_) = _each($args, $k)) {
             if (isStr($i)) {
                 $this->do_method($i, $v_);
             }
             if (isDrw(OBJ($v_))) {
                 foreach ($v_ as $l => $v1) {
                     $this->do_method($l, $v1);
                 }
             }
         }
     }
     return $this;
 }
开发者ID:hoangsoft90,项目名称:hw-sudoku-wordpress,代码行数:35,代码来源:hphp.php

示例2: clone_

/**
 * Returns a deep copy of the given value. `Callable`s are not copied but returned by reference.
 * ```php
 * $data = (object) [
 *     'content' => (object) ['name' => 'foo'],
 *     'other' => 'value'
 * ];
 *
 * $clonedData = clone_($data);
 * $clonedData->content->name = 'bar';
 *
 * $clonedData; // stdClass({content: {name: 'bar'}, other: 'value'})
 * $data; // stdClass({content: {name: 'foo'}, other: 'value'})
 * ```
 *
 * @signature a -> a
 * @param  mixed $value
 * @return mixed
 */
function clone_()
{
    $clone = function ($value) {
        switch (type($value)) {
            case 'Null':
            case 'Boolean':
            case 'String':
            case 'Function':
            case 'Resource':
            case 'Number':
                return $value;
            case 'ArrayObject':
            case 'Array':
            case 'List':
                return map(clone_(), $value);
            case 'Error':
            case 'Stream':
            case 'Object':
                $result = clone $value;
                foreach (keys($value) as $key) {
                    $result->{$key} = clone_($result->{$key});
                }
                return $result;
        }
        return $value;
    };
    return apply(curry($clone), func_get_args());
}
开发者ID:tarsana,项目名称:functional,代码行数:47,代码来源:object.php

示例3: of

 /**
  * Creates a new Stream with the provided $data.
  * ```php
  * Stream::of(1); // Stream(1)
  * Stream::of(1, 'Hello'); // Stream([1, 'Hello'])
  * Stream::of([1, 2, 3]); // Stream([1, 2, 3])
  * ```
  *
  * @signature a -> Stream(a)
  * @param  mixed $data
  * @return Stream
  */
 public static function of($data)
 {
     $data = func_get_args();
     if (count($data) == 1) {
         $data = $data[0];
     }
     return new Stream($data, [], type($data));
 }
开发者ID:tarsana,项目名称:functional,代码行数:20,代码来源:Stream.php

示例4: assign_link

function assign_link(&$o, $url = '', $targ = '_parent')
{
    if (type(OBJ($o, false)) == 'a') {
        _($o)->attr(array('href' => $url, 'target' => $targ));
    } else {
        $l = c_link($o, $url, $targ);
        _($o)->parent()->replaceChild($o, $l);
        $o = $l;
    }
}
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:10,代码来源:hphp.plugin_Element.php

示例5: valid_datetime_object

 function valid_datetime_object($t)
 {
     //only date
     if (type($t) == '_Date') {
         $y = $t->get_date();
     } elseif (type($t) == 'DateTime') {
         $y = $t;
     }
     if (isStr($t) && isDate($t)) {
         $s = explode('-', $t);
         $y = new DateTime();
         $y->setDate($s[0], $s[1], $s[2]);
     }
     if (isset($y)) {
         return $y;
     } else {
         return false;
     }
 }
开发者ID:hoangsoft90,项目名称:hw-sudoku-wordpress,代码行数:19,代码来源:hphp._Date.php

示例6: type

function type($fid = 0, $n = 0, $fstr)
{
    $fstr .= ">" . $fid;
    $n++;
    //获取fid对应的分类
    $ob = M("producttype");
    $arr = $ob->where("fid={$fid}")->select();
    /*
    echo"<pre>";
    echo $n;
    var_dump($arr);
    echo"</pre>";
    */
    for ($i = 1; $i < $n; $i++) {
        $kStr .= "&nbsp;&nbsp;";
    }
    foreach ($arr as $v) {
        $id = $v['id'];
        $newFstr = substr($fstr, 2);
        if ($n == 1) {
            $str .= "<option value='{$newFstr}>{$id}>'>{$v['name']}</option>";
        } else {
            $str .= "<option value='{$newFstr}>{$id}>'>{$kStr}{$v['name']}</option>";
        }
        //查找$id是否有子分类,找到它的子分类对应的数组
        $sarr = $ob->where("fid={$id}")->select();
        /*echo"<pre>";
          var_dump($arr);
          echo"</pre>";*/
        if (!empty($sarr) && is_array($sarr)) {
            $str1 = type($id, $n, $fstr);
            $str = $str . $str1;
        }
    }
    return $str;
}
开发者ID:xiaoyueer98,项目名称:m-heimiwifi-com,代码行数:36,代码来源:common.php

示例7: time

require_once '../models/data/ItemInfo.php';
$des_name = time();
$im = new ItemInfo();
try {
    $fp = fopen('./12345', 'r');
    $data = array();
    while (!feof($fp)) {
        $line = fgets($fp);
        $line = preg_replace('/\\t{1,}/', ' ', $line);
        //去掉多个tab制表位
        $line = preg_replace('/\\s{2,}/', ' ', $line);
        //去掉多个空格
        $l = explode(" ", $line);
        $l[1] = gender($l[1]);
        $l[2] = type($l[2]);
        if ($l[0] == null) {
            continue;
        }
        $data[] = $l;
    }
    $cons = '`id`,`itemGender`,`type`,`itemName`,`itemDate`';
    $ln = null;
    foreach ($data as $k => $v) {
        $time = time();
        array_walk($v, 'trim_arr');
        $ln .= '(\'';
        $ln .= join($v, '\',\'');
        $ln .= '\',\'' . $time . '\'),';
    }
    $ln = trim($ln, ",") . ';';
开发者ID:bmchun,项目名称:sunset,代码行数:30,代码来源:import.php

示例8: string

function string()
{
    type('is_string', func_get_args());
}
开发者ID:tfarla,项目名称:want-type,代码行数:4,代码来源:type.php

示例9: die

 $sql = "SELECT * FROM users WHERE username = '{$username}' AND password = '{$password}'";
 $result = @$database->query($sql) or die("No.");
 // Huge error
 // Cookies don't match and no session, so tell them to logout!
 if ($database->num($result) < 1) {
     session_destroy();
     unset($username);
     unset($password);
     include $config['template_path'] . "header.php";
     print_out(lang('error_with_cookies'), lang_parse('error_cookie_body', array($config['url_path'] . '/logout.php')), false);
 } else {
     if ($database->num($result) > 0) {
         // Get the users data
         $user_data = $database->fetch($result);
         // What is this user classified as?
         $type = type($user_data['username']);
         // Tell us what they are
         switch ($type) {
             case 1:
                 $_SESSION['admin'] = true;
                 break;
             case 2:
                 $_SESSION['moderator'] = true;
                 break;
             case 3:
                 $_SESSION['banned'] = true;
                 break;
             default:
                 break;
         }
         // Update their session
开发者ID:nijikokun,项目名称:NinkoBB,代码行数:31,代码来源:sessions.php

示例10: login

/**
 * Signs user in based on username or email
 * @global array 
 * @global resource
 * @param boolean|string $username username or false
 * @param boolean|string $email user email or false
 * @param string $password user password
 * @return int|boolean
 */
function login($username, $email = false, $password)
{
    global $config, $database;
    // Error codes
    //	904		- empty email
    //	905		- invalid email
    //	906		- invalid username
    //	907		- invalid chars in username
    //  908		- banned [.]
    // email is true?
    if ($email) {
        // is just true or null?
        if (empty($email)) {
            return 904;
        }
        // are we using email?
        if (is_email($email)) {
            // Encrypt the password
            $password = md5($password);
            // login before
            load_hook('login_before');
            // Query
            $query = "SELECT * FROM `users` WHERE `email` = '{$email}' AND `password` = '{$password}' LIMIT 1";
            // Return Data
            $return = $database->query($query);
            // Exists?
            if ($database->num($return) > 0) {
                // Finally return Results
                $user_data = $database->fetch($return);
                // Are they banned?
                if ($user_data['banned']) {
                    return 908;
                }
                // What is this user classified as?
                $type = type($user_data['username']);
                // Tell us what they are
                switch ($type) {
                    case 1:
                        $_SESSION['admin'] = true;
                        break;
                    case 2:
                        $_SESSION['moderator'] = true;
                        break;
                    case 3:
                        $_SESSION['banned'] = true;
                        break;
                    default:
                        break;
                }
                // logged in
                load_hook('login_after');
                // Update their session
                $_SESSION['logged_in'] = true;
                $_SESSION['user_id'] = $user_data['id'];
                $_SESSION['user_name'] = $user_data['username'];
                // Last seen
                update_user($user_data['id'], false, 'last_seen', time());
                // Set Cookie
                if ($config['allow_cookies']) {
                    setcookie('login', "{$username}|{$password}", time() + 86400 * 365 * 2, $config['cookie_domain'], '.ninkobb.com');
                }
            } else {
                return false;
            }
        } else {
            // guess it wasn't a real one.
            return 905;
        }
    } else {
        // Was it empty?
        if (empty($username)) {
            return 906;
        }
        // Checking for invalid characters
        if (!alpha($username, 'alpha-underscore')) {
            return 907;
        }
        // Encrypting password
        $password = md5($password);
        // login before
        load_hook('login_before');
        // Query
        $query = "SELECT * FROM `users` WHERE `username` = '{$username}' AND `password` = '{$password}' LIMIT 1";
        // Return Data
        $return = $database->query($query);
        // Exists?
        if ($database->num($return) > 0) {
            // Finally return Results
            $user_data = $database->fetch($return);
            // Are they banned?
            if ($user_data['banned']) {
//.........这里部分代码省略.........
开发者ID:nijikokun,项目名称:NinkoBB,代码行数:101,代码来源:user.php

示例11: isset

    $n = isset($_GET['limit']) ? $_GET['limit'] : null;
    $search = new Search();
    $like = new UserLikeModel();
    $re = $search->search($_GET['key'], $page, $uid, $n);
    while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
        $line['islike'] = $like->checkUserLike($uid, $line['id']);
        $line['likesum'] = $like->itemLikeSum($line['id']);
        $data[] = $line;
    }
    echo $style->show(200, $data);
} elseif ($_GET['key'] && $_GET['type']) {
    $data = array();
    $uid = isset($_GET['uid']) ? $_GET['uid'] : null;
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    if (isset($_GET['type'])) {
        $type = type($_GET['type']);
    }
    $search = new Search();
    $like = new UserLikeModel();
    $re = $search->search_admin($_GET['key'], $type, $page);
    while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
        $line['islike'] = $like->checkUserLike($uid, $line['id']);
        $line['likesum'] = $like->itemLikeSum($line['id']);
        $data[] = $line;
    }
    echo $style->show(200, $data);
} else {
    echo $style->show(400);
}
function type($type)
{
开发者ID:bmchun,项目名称:sunset,代码行数:31,代码来源:search.php

示例12: replaceChild

 function replaceChild($new, $old = null)
 {
     if (!$this->more()) {
         if (isDrw($new) || type($new) == 'DRW') {
             while (list($i, $v) = _each($new, $k)) {
                 $this->replaceChild($i, $v);
             }
         }
         if (isEle($new) && isEle($old)) {
             $this->O->replaceChild($new, $old);
         }
     } else {
         foreach ($this->O as $v) {
             _($v)->replaceChild($new, $old);
         }
     }
     return $this;
 }
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:18,代码来源:hphp.class_Element.php

示例13: equals

/**
 * Returns `true` if the two elements have the same type and are deeply equivalent.
 * ```php
 * $a = (object) ['a' => 1, 'b' => (object) ['c' => 'Hello'], 'd' => false];
 * $b = (object) ['a' => 1, 'b' => (object) ['c' => 'Hi'], 'd' => false];
 * $c = (object) ['a' => 1, 'b' => ['c' => 'Hello'], 'd' => false];
 * equals(5, '5'); // false (should have the same type)
 * equals([1, 2, 3], [1, 2, 3]); // true
 * equals([1, 3, 2], [1, 2, 3]); // false (should have the same order)
 * equals($a, $b); // false
 * equals($a, $c); // false
 * $b->b->c = 'Hello';
 * equals($a, $b); // true
 * ```
 *
 * @signature * -> * -> Boolean
 * @param  mixed $a
 * @param  mixed $b
 * @return bool
 */
function equals()
{
    $equals = function ($a, $b) {
        $type = type($a);
        if ($type != type($b)) {
            return false;
        }
        switch ($type) {
            case 'Null':
            case 'Boolean':
            case 'String':
            case 'Number':
            case 'Unknown':
            case 'Function':
            case 'Resource':
            case 'Error':
            case 'Stream':
                return $a == $b;
            case 'List':
                $length = length($a);
                return length($b) != $length ? false : 0 == $length ? true : equals(head($a), head($b)) && equals(tail($a), tail($b));
            case 'Array':
            case 'ArrayObject':
            case 'Object':
                return equals(keys($a), keys($b)) && equals(values($a), values($b));
        }
    };
    return apply(curry($equals), func_get_args());
}
开发者ID:tarsana,项目名称:functional,代码行数:49,代码来源:operators.php

示例14: elementType

{
    return "type {$argNum}";
}
/**
 * element type of argument #$argNum
 * @param mixed $argNum
 * @return mixed
 */
function elementType($argNum)
{
    return "elementType {$argNum}";
}
override(\array_shift(0), elementType(0));
override(\array_reverse(0), elementType(0));
override(\array_pop(0), elementType(0));
//  override(\array_map(0), type(1));
override(\array_filter(0), type(0));
override(\array_reduce(0), elementType(0));
override(\current(0), elementType(0));
override(\reset(0), elementType(0));
override(\end(0), elementType(0));
override(\prev(0), elementType(0));
override(\next(0), elementType(0));
override(\iterator_to_array(0), type(0));
//  override( \ServiceLocatorInterface::get(0),
//    map( [
//      "A" => \Exception::class,
//      \ExampleFactory::EXAMPLE_B => ExampleB::class,
//      \EXAMPLE_B => \ExampleB::class,
//      '' =>  '@|\Iterator',
//    ]));
开发者ID:artspb,项目名称:phpstorm-stubs,代码行数:31,代码来源:.phpstorm.meta.php

示例15: displayLobby

function displayLobby($id, $full = false, $ready = false, $rate = false)
{
    $lobby = new lobby($id);
    $sid = $lobby->lobbyserver($id);
    $server = new Server($sid);
    echo '<li class="lobby_panel" data-panel="lobby_tooltip-' . $lobby->id . '">
			<img class="map_pic" src="theme/images/maps/' . $lobby->map . '.jpg">
			<div class="panel_left">
				<h1>' . $lobby->name . '</h1>
				<span class="date">' . date('g:i a', strtotime($lobby->date)) . '</span>
				<span class="map">' . $lobby->map . '</span>
				<ul class="classes">
					<li><img src="theme/images/class/scout.png" height="18"></li>
					<li><img src="theme/images/class/soldier.png" height="18"></li>
					<li><img src="theme/images/class/demo.png" height="18"></li>
					<li><img src="theme/images/class/heavy.png" height="18"></li>
					<li><img src="theme/images/class/sniper.png" height="18"></li>					
					<li><img src="theme/images/class/medic.png" height="18"></li>
				</ul>
			</div>
			<div class="panel_right">
						<span class="skillevel skill_higher">Division ' . $lobby->division . '</span>
						<span class="matchtype">' . type($lobby->type) . '</span>
						<span class="playercount"><span class="currentplayers">' . countPlayers($lobby->id) . '</span>/<span class="maxplayers">' . 2 * teamplayers($lobby->type) . '</span></span>
			</div>
			</li>';
    if ($full) {
        echo '<li class="lobby_tooltip_big" id="lobby_tooltip:' . $lobby->id . '">';
    } else {
        echo '<li class="lobby_tooltip" id="lobby_tooltip:' . $lobby->id . '">';
    }
    echo '
			<ul class="blue_players">
				<li class="teamname blu">BLU</li>';
    if (!$ready && !$rate) {
        echo $lobby->players_blu;
    }
    if ($ready && !$rate) {
        echo displayLobbyPlayers($lobby->id, $lobby->type, 1, true, false);
    }
    if (!$ready && $rate) {
        echo displayLobbyPlayers($lobby->id, $lobby->type, 1, false, true);
    }
    echo '
			</ul>
			<ul class="red_players">
				<li class="teamname red">RED</li>';
    if (!$ready && !$rate) {
        echo $lobby->players_red;
    }
    if ($ready && !$rate) {
        echo displayLobbyPlayers($lobby->id, $lobby->type, 2, true, false);
    }
    if (!$ready && $rate) {
        echo displayLobbyPlayers($lobby->id, $lobby->type, 2, false, true);
    }
    echo '
			</ul>';
    if ($full) {
        echo '
			<h1 style="margin-top: 10px;  margin-right: 5px;">Spectators:</h1>
			<ul class="spec_players" style="margin-top: 10px; float: left;">' . $lobby->players_spec . '
			</ul><h1 style="margin-top: 10px;  margin-right: 5px; clear: left;">Info:</h1>
					<ul style="margin-top: 10px; float: left;">
						<li>Lobby started at 14:23 and has now been running for <span class="time_run">13</span> minutes.</li>
					</ul>
		</li>';
    } else {
        echo '<div class="lobby_info">
						<h1>Gameserver</h1>
						' . $server->showServer() . '' . ($_SESSION['id'] ? '<div class="button join" onclick="joinGame(' . $lobby->id . ')">Join</div>' : '') . '
						
					</div>';
    }
}
开发者ID:marat1803,项目名称:tf2matchmaking,代码行数:75,代码来源:class.lobby.php


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