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


PHP sub函数代码示例

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


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

示例1: pad

/**
 * UTF-8 aware alternative to str_pad.
 *
 * $pad_str may contain multi-byte characters.
 *
 * @author     Oliver Saunders <oliver@osinternetservices.com>
 * @package    php-utf-8
 * @subpackage functions
 * @see        http://www.php.net/str_pad
 * @uses       utf8_substr
 *
 * @param string $input
 * @param int    $length
 * @param string $pad_str
 * @param int    $type    (same constants as str_pad)
 *
 * @return string
 */
function pad($input, $length, $pad_str = ' ', $type = STR_PAD_RIGHT)
{
    $input_len = len($input);
    if ($length <= $input_len) {
        return $input;
    }
    $pad_str_len = len($pad_str);
    $pad_len = $length - $input_len;
    if ($type == STR_PAD_RIGHT) {
        $repeat_times = ceil($pad_len / $pad_str_len);
        return sub($input . str_repeat($pad_str, $repeat_times), 0, $length);
    }
    if ($type == STR_PAD_LEFT) {
        $repeat_times = ceil($pad_len / $pad_str_len);
        return sub(str_repeat($pad_str, $repeat_times), 0, floor($pad_len)) . $input;
    }
    if ($type == STR_PAD_BOTH) {
        $pad_len /= 2;
        $pad_amount_left = floor($pad_len);
        $pad_amount_right = ceil($pad_len);
        $repeat_times_left = ceil($pad_amount_left / $pad_str_len);
        $repeat_times_right = ceil($pad_amount_right / $pad_str_len);
        $padding_left = sub(str_repeat($pad_str, $repeat_times_left), 0, $pad_amount_left);
        $padding_right = sub(str_repeat($pad_str, $repeat_times_right), 0, $pad_amount_right);
        return $padding_left . $input . $padding_right;
    }
    trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
开发者ID:corpsee,项目名称:php-utf-8,代码行数:46,代码来源:str_pad.php

示例2: sub

function sub($items, $id, $count)
{
    $count++;
    echo '<ul>';
    foreach ($items as $item) {
        if ($item['parent'] == $id) {
            echo '<li><label><input type="checkbox" value="' . $item['id'] . '">' . $item['title'] . '</label></li>';
            sub($items, $item['id'], $count);
        }
    }
    echo '</ul>';
}
开发者ID:ahadabasi,项目名称:edu7-01,代码行数:12,代码来源:addworksample.php

示例3: cspn

/**
 * UTF-8 aware alternative to strcspn.
 *
 * Find length of initial segment not matching mask.
 *
 * @package    php-utf-8
 * @subpackage functions
 * @see        http://www.php.net/strcspn
 * @uses       utf8_strlen
 * @uses       utf8_substr
 *
 * @param string  $str
 * @param string  $mask
 * @param integer $start
 * @param integer $length
 *
 * @return integer|null
 */
function cspn($str, $mask, $start = null, $length = null)
{
    if (empty($mask) || strlen($mask) == 0) {
        return null;
    }
    $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\\${1}', $mask);
    if ($start !== null || $length !== null) {
        $str = sub($str, $start, $length);
    }
    preg_match('/^[^' . $mask . ']+/u', $str, $matches);
    if (isset($matches[0])) {
        return len($matches[0]);
    }
    return 0;
}
开发者ID:corpsee,项目名称:php-utf-8,代码行数:33,代码来源:strcspn.php

示例4: checkTokenError

 /**
  * Проверка пользовательских данных, полученных по токену
  */
 protected function checkTokenError()
 {
     if (!is_array($this->u_data)) {
         $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => $this->user->lang['ULOGIN_WRONG_USER_DATA_ERROR'], 'type' => 'error'));
         return false;
     }
     if (isset($this->u_data['error'])) {
         $strpos = strpos($this->u_data['error'], 'host is not');
         if ($strpos) {
             $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => sprintf($this->user->lang['ULOGIN_HOST_ADDRESS_ERROR'], sub($this->u_data['error'], intval($strpos) + 12)), 'type' => 'error'));
             return false;
         }
         switch ($this->u_data['error']) {
             case 'token expired':
                 $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => $this->user->lang['ULOGIN_TOKEN_EXPIRED_ERROR'], 'type' => 'error'));
                 break;
             case 'invalid token':
                 $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => $this->user->lang['ULOGIN_INVALID_TOKEN_ERROR'], 'type' => 'error'));
                 break;
             default:
                 $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => "<i>ERROR</i>: " . $this->u_data['error'], 'type' => 'error'));
         }
         return false;
     }
     if (!isset($this->u_data['identity'])) {
         $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => sprintf($this->user->lang['ULOGIN_NO_VARIABLE_ERROR'], 'identity'), 'type' => 'error'));
         return false;
     }
     if (!isset($this->u_data['email'])) {
         $this->sendMessage(array('title' => $this->user->lang['ULOGIN_AUTH_ERROR'], 'msg' => sprintf($this->user->lang['ULOGIN_NO_VARIABLE_ERROR'], 'email'), 'type' => 'error'));
         return false;
     }
     return true;
 }
开发者ID:mike-a-b,项目名称:crossfit,代码行数:37,代码来源:main.php

示例5: sub

function sub($items, $id, $count)
{
    $count++;
    foreach ($items as $item) {
        if ($item['parent'] == $id) {
            echo '<tr class="category-wrap-main">
                                <td><input value="' . $item['id'] . '" type="checkbox"/></td>
                                <td>';
            for ($i = 0; $i < $count; $i++) {
                echo " - ";
            }
            echo $item['title'] . "</a></td>";
            echo '<td>' . $item['describe_category'] . '</td>                                
                                <td>
                                    <a href="" class="quickedit-btn">ویرایش سریع</a> | 
                                    <a href="update-catws.php?id=' . $item['id'] . '" class="lupwsc">ویرایش</a> | 
                                    <a href="" class="quickdelete-btn">حذف</a>
                                </td>     
                            </tr>';
            echo '<tr class="quickedit">
                            	<td colspan="5">
                                    <fieldset>
                                    	<h4>ویرایش سریع</h4>
                                        <div>
                                        	<div class="col-md-1"><label for="">نام</label></div>
                                            <div class="col-md-11">
                                            	<input type="text" class="ptitle" value="' . $item['title'] . '"/>
                                            </div>
                                        </div>
                                        
                                        <div>
                                        	<div class="col-md-1"><label class="wrap-txt-quick-edit" for="">توضیح</label></div>
                                            <div class="col-md-11">
                                            	<input type="text" class="ptitle" value="' . $item['describe_category'] . '"/>
                                            </div>
                                        </div>
                                        <div class="quick-edit-wrap-btn">
                                        	<input type="submit" class="btn btn-default btn-sm quick-edit-cancel-btn" value="لغو">
                                            <input type="submit" class="btn btn-primary text-left btn-sm quick-update" value="بروز رسانی">
                                        </div>';
            sub($items, $item['id'], $count);
        }
    }
}
开发者ID:ahadabasi,项目名称:edu7-01,代码行数:44,代码来源:insert-catws.php

示例6: ulogin_check_token_error

/**
 * Проверка пользовательских данных, полученных по токену
 * @param $u_user - пользовательские данные
 * @return bool
 */
function ulogin_check_token_error($u_user)
{
    if (!is_array($u_user)) {
        wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "Данные о пользователе содержат неверный формат."), 'uLogin error', array('back_link' => true));
        return false;
    }
    if (isset($u_user['error'])) {
        $strpos = strpos($u_user['error'], 'host is not');
        if ($strpos) {
            wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: адрес хоста не совпадает с оригиналом") . sub($u_user['error'], intval($strpos) + 12), 'uLogin error', array('back_link' => true));
        }
        switch ($u_user['error']) {
            case 'token expired':
                wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: время жизни токена истекло"), 'uLogin error', array('back_link' => true));
                break;
            case 'invalid token':
                wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: неверный токен"), 'uLogin error', array('back_link' => true));
                break;
            default:
                wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "<i>ERROR</i>: ") . $u_user['error'], 'uLogin error', array('back_link' => true));
        }
        return false;
    }
    if (!isset($u_user['identity'])) {
        wp_die(__("<b>Ошибка работы uLogin:</b></br></br>" . "В возвращаемых данных отсутствует переменная <b>identity</b>."), 'uLogin error', array('back_link' => true));
        return false;
    }
    return true;
}
开发者ID:ultr0,项目名称:TM-FreeTV,代码行数:34,代码来源:ulogin.php

示例7: div

function div($x, $y)
{
    return lt($x, $y) ? 0 : add(1, div(sub($x, $y), $y));
}
开发者ID:emkay,项目名称:php-phant,代码行数:4,代码来源:math.php

示例8: checkTokenError

 /**
  * Проверка пользовательских данных, полученных по токену
  */
 protected function checkTokenError()
 {
     if (!is_array($this->u_data)) {
         $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => 'ulogin_wrong_user_data_error', 'type' => 'error'));
         return false;
     }
     if (isset($this->u_data['error'])) {
         $strpos = strpos($this->u_data['error'], 'host is not');
         if ($strpos) {
             $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_host_address_error', sub($this->u_data['error'], intval($strpos) + 12)), 'type' => 'error'));
             return false;
         }
         switch ($this->u_data['error']) {
             case 'token expired':
                 $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => 'ulogin_token_expired_error', 'type' => 'error'));
                 break;
             case 'invalid token':
                 $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => 'ulogin_invalid_token_error', 'type' => 'error'));
                 break;
             default:
                 $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => "<i>ERROR</i>: " . $this->u_data['error'], 'type' => 'error'));
         }
         return false;
     }
     if (!isset($this->u_data['identity'])) {
         $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'identity'), 'type' => 'error'));
         return false;
     }
     if (!isset($this->u_data['email'])) {
         $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'email'), 'type' => 'error'));
         return false;
     }
     if (!isset($this->u_data['first_name'])) {
         $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'first_name'), 'type' => 'error'));
         return false;
     }
     if (!isset($this->u_data['last_name'])) {
         $this->sendMessage(array('title' => 'ulogin_auth_error', 'msg' => array('ulogin_no_variable_error', 'last_name'), 'type' => 'error'));
         return false;
     }
     return true;
 }
开发者ID:vadimtimofieiev,项目名称:ulogin-OpenCart,代码行数:45,代码来源:ulogin.php

示例9: sub

 public function sub($other)
 {
     return sub($this, $other);
 }
开发者ID:Vinceveve,项目名称:php-rql,代码行数:4,代码来源:misc.php

示例10: soma

<pre><?php 
include 'cal.php';
echo '5 + 2= ' . soma(5, 2) . '<br>';
echo '5 - 2= ' . sub(5, 2) . '<br>';
echo '5 / 2= ' . div(5, 2) . '<br>';
echo '5 * 2= ' . mult(5, 2) . '<br>';
echo '5 + 2 * 3= ' . soma(5, mult(2, 3)) . '<br>';
echo '8 - 3 + 5= ' . soma(sub(8, 3), 5) . '<br>';
echo '9 / 3 + 4 * 2= ' . soma(div(9, 3), mult(4, 2)) . '<br>';
?>
</pre>
开发者ID:RicardoRamos,项目名称:cal2,代码行数:11,代码来源:cal_test.php

示例11: while

<?php

if (!defined('InEmpireCMS')) {
    exit;
}
$i = 0;
$line = 3;
//每行显示图片数
$width = 100;
$height = 80;
$sub = 23;
//编号截取数
while ($r = $empire->fetch($sql)) {
    $ono = $r[no];
    $r[no] = sub($r[no], 0, $sub, false);
    $filesize = ChTheFilesize($r[filesize]);
    //文件大小
    $filetype = GetFiletype($r[filename]);
    //取得文件扩展名
    $i++;
    if (($i - 1) % $line == 0 || $i == 1) {
        $class_text .= "<tr bgcolor='#DBEAF5'>";
    }
    //文件
    $fspath = ReturnFileSavePath($r[classid], $r[fpath]);
    $filepath = $r[path] ? $r[path] . '/' : $r[path];
    $file = $fspath['fileurl'] . $filepath . $r[filename];
    $buttonr = ToReturnDoFileButton($doing, $tranfrom, $field, $file, $r[filename], $r[fileid], $filesize, $filetype, $ono, $type);
    $button = $buttonr['button'];
    $buttonurl = $buttonr['bturl'];
    $class_text .= "<td><table width='100%' border='0' cellspacing='1' cellpadding='2'>\n  <tr> \n    <td width='96%' rowspan='2'><div align='center'><a href='#empirecms' title='点击选择' onclick=\"javascript:" . $buttonurl . "\"><img src='" . $file . "' width='" . $width . "' height='" . $height . "' border=0></a></div></td>\n    <td width='4%' valign='top'> <div align='center'> \n        <input type=checkbox name=fileid[] value='{$r['fileid']}'>\n      </div></td>\n  </tr>\n  <tr>\n    <td valign='bottom'>\n<div align='center'><a href='cropimg/CropImage.php?fileid=" . $r[fileid] . "&filepass=" . $filepass . "&classid={$classid}&infoid={$infoid}&modtype={$modtype}&fstb={$fstb}" . $ecms_hashur['ehref'] . "' target='_blank' title='裁剪'><img src='../../data/images/cropimg.gif' width='13' height='13' border='0'></a></div></td>\n  </tr>\n  <tr> \n    <td><div align='center'><a title='" . $ono . "'>" . $r[no] . "</a></div></td>\n    <td><div align='center'><a href='../../ViewImg/index.html?url=" . $file . "' target='_blank' title='预览:" . $r[filename] . "'><img src='../../data/images/viewimg.gif' width='13' height='13' border='0'></a></div></td>\n  </tr>\n</table></td>";
开发者ID:novnan,项目名称:meiju,代码行数:31,代码来源:editorpic.php

示例12: sub

function sub($items, $id, $segment1, $segment2)
{
    echo "<ul class='treeview-menu'>";
    foreach ($items as $item) {
        if ($item['parent_id'] == $id) {
            $active = '';
            if ("{$segment1}/{$segment2}" == $item['menu_url']) {
                $active = 'class="active"';
            }
            $menu_url = base_url($item['menu_url']);
            echo "<li {$active}>\n              <a href='{$menu_url}'>\n                <i class='fa {$item['menu_icon']}'></i>{$item['menu_name']}\n              </a>";
            foreach ($items as $value) {
                if ($value['parent_id'] == $item['menu_id']) {
                    sub($items, $item['menu_id'], $segment1, $segment2);
                    break;
                }
            }
            echo "</li>";
        }
    }
    echo "</ul>";
}
开发者ID:Gincusoft,项目名称:aksi,代码行数:22,代码来源:template.php

示例13: sub

						<form method="post" action="" name='sub'>
							<input class="textbox2" type="email" name="emailxxx" placeholder="Nhập địa chỉ email..." autocomplete="off" required>&nbsp;&nbsp;
							<button type='submit' name='sub' style='background-color: #fff; border: 0;' ><input width="25px" height="25px" type="image" onclick='document.getElementById("sub").submit();' style='margin: -6px; background-color: #fff;' src="./images/sub.png" alt="Gửi" title="Gửi"></input></button>
							<br/>
						</form>
						<div id="form2">
						<h3>Đăng ký nhận đề kiểm tra mới</h3>
						<div>
							<span id="form_content2"> 
							</span>
						</div>
						<span id="form_close2"></span>
						</div>
						<?php 
if (isset($_POST["emailxxx"])) {
    sub();
}
?>
						</div>
							<div class="clear"></div>
						</div>
						<div class="boxnav">
							<h3 class="titlenav" style="margin-bottom: -2px;"><a href="#" class="menuitem submenuheader">Danh mục đề kiểm tra</a></h3>
		<ul class="navigation">
		<?php 
if ($this3 == NULL) {
    $this3 = 1;
}
$sql = "SELECT * FROM `cate3`";
$query = @mysql_query($sql);
$i = 0;
开发者ID:h2dvnnet,项目名称:dekiemtra,代码行数:31,代码来源:header.php

示例14: add

<?php

require "example.php";
# First create some objects using the pointer library.
print "Testing the pointer library\n";
$a = 37.145;
$b = 42.555;
$c = "";
// $c must be defined and not null.
print "\ta = {$a}\n";
print "\tb = {$b}\n";
print "\tc = {$c}\n";
# Call the add() function wuth some pointers
add($a, $b, $c);
print "\t{$a} + {$b} = {$c}\n";
# Now try the typemap library
# This should be much easier. Now how it is no longer
# necessary to manufacture pointers.
print "Trying the typemap library\n";
$r = sub(37, 42);
print "\t37 - 42 = {$r}\n";
# Now try the version with multiple return values
# print "Testing multiple return values\n";
# ($q,$r) = divide(42,37);
# print "	42/37 = $q remainder $r\n";
开发者ID:msornay,项目名称:swig,代码行数:25,代码来源:runme.php

示例15: icod

function icod()
{
    echo "<form action=\"" . $php . "\" method=\"post\">\n<div align =\"center\"><b>Upload File";
    are('code', 'Post your code here', '50', '20', '<br>');
    inp('text', '40', 'upf', path, 'File Name');
    echo "<br>";
    sub('upff', 'upload', '<br>');
    echo "<a href=\"javascript: history.go(-1)\">Back</a></div>";
}
开发者ID:retanoj,项目名称:webshellSample,代码行数:9,代码来源:3f043fd6edd0192a61e1ab53118b86b2.php


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