本文整理汇总了PHP中extend函数的典型用法代码示例。如果您正苦于以下问题:PHP extend函数的具体用法?PHP extend怎么用?PHP extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extend函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: omnimatch
function omnimatch($password)
{
global $MATCHERS;
$matches = array();
foreach ($MATCHERS as $matcher) {
extend($matches, $matcher($password));
}
$compare_function = function ($match1, $match2) {
return $match1['i'] - $match2['i'] or $match1['j'] - $match2['j'];
};
usort($matches, $compare_function);
return $matches;
}
开发者ID:benrolfe,项目名称:php-zxcvbn,代码行数:13,代码来源:matching.php
示例2: get_server_list
public static function get_server_list($args = array())
{
global $db;
$defaults = array('funcs' => array('count' => array('func' => 'count', 'param' => '%02d'), 'link' => array('func' => 'link'), 'label' => array('func' => 'label')), 'query' => 'SELECT * FROM tf2_servers LIMIT 10;');
$s = extend($defaults, $args);
$mlq = $db->query($s['query']);
while ($row = $db->fetch_array($mlq)) {
$cols = array();
foreach ($s['funcs'] as $key => $f) {
$val = server_functions::$f['func']($f['param'], $row);
$row[$key] = $val;
}
$rows[] = $row;
}
return $rows;
}
开发者ID:mwilchez,项目名称:master,代码行数:16,代码来源:server.php
示例3: extend
/**
* array_merge inteligente
* @param array $initial
* @param array $merge
* @return array
*/
function extend(array $initial = null, array $merge = null)
{
if ($merge and $initial) {
foreach ($merge as $key => $value) {
if (is_int($key)) {
$initial[] = $value;
} else {
if (is_array($value) and isset($initial[$key])) {
$initial[$key] = extend($initial[$key], $value);
} else {
$initial[$key] = $value;
}
}
}
}
return $initial;
}
开发者ID:jhonlennon,项目名称:estrutura-mvc,代码行数:23,代码来源:core.php
示例4: array_recursiveMergeInto
/**
* Merges an array or an object to the target array, modifying the original, recursively.
* It supports nested object properties.
*
* @param array $a Target being modified.
* @param array|object|Traversable $b Source data.
*/
function array_recursiveMergeInto(array &$a, $b)
{
foreach ($b as $k => $v) {
if (!isset($a[$k])) {
$a[$k] = $v;
} else {
$c = $a[$k];
if (is_array($c)) {
$a[$k] = array_merge($c, $v);
} elseif (is_object($c)) {
extend($c, $v);
} else {
$a[$k] = $v;
}
}
}
}
开发者ID:php-kit,项目名称:tools,代码行数:24,代码来源:arrays.php
示例5: preRender
protected function preRender()
{
$prop = $this->props;
if ($link = $prop->link) {
extend($prop, ['label' => $link->title(), 'href' => $link->url(), 'icon' => $link->icon(), 'active' => $link->isActive()]);
}
$this->disabled = is_null($prop->href) && !exists($prop->script) || $prop->disabled;
if ($this->disabled) {
$this->addClass($prop->disabledClass);
}
if ($prop->active || exists($prop->href) && str_beginsWith($prop->currentUrl, $prop->href) || $prop->href === '' && $prop->currentUrl === '') {
$this->cssClassName = $prop->activeClass;
}
if (!empty($prop->wrapper)) {
$this->containerTag = $prop->wrapper;
}
parent::preRender();
}
开发者ID:electro-modules,项目名称:matisse-components,代码行数:18,代码来源:Link.php
示例6: _filter_input
/**
*
* @param int $type
* @param string $variable_name
* @param string|int $filter
* @param array $options
*/
function _filter_input($type, $variable_name = null, $filter = 'FILTER_DEFAULT', $options = null)
{
# Fitlro
if ($filter === null or $filter == 'FILTER_DEFAULT') {
$filter = FILTER_DEFAULT;
}
# Return Array
if ($variable_name === null) {
$extraValues = [];
switch ($type) {
case INPUT_POST:
$extraValues = $_POST;
break;
case INPUT_GET:
$extraValues = $_GET;
break;
case INPUT_SERVER:
$extraValues = $_SERVER;
break;
}
return extend($extraValues, (array) filter_input_array($type));
} else {
$value = filter_input($type, $variable_name, $filter, $options);
if ($value === null) {
switch ($type) {
case INPUT_POST:
$value = isset($_POST[$variable_name]) ? $_POST[$variable_name] : $value;
break;
case INPUT_GET:
$value = isset($_GET[$variable_name]) ? $_GET[$variable_name] : $value;
break;
case INPUT_SERVER:
$value = isset($_SERVER[$variable_name]) ? $_SERVER[$variable_name] : $value;
break;
}
return filter_var($value, $filter, $options);
} else {
return $value;
}
}
}
开发者ID:jhonlennon,项目名称:estrutura-mvc,代码行数:48,代码来源:input.php
示例7: euclideanDistance
/**
* Euclidean Distance
* 2014-INS-Distance and similarity measures for hesitant fuzzy linguistic term sets and their application in multi-criteria decision making
* In: Array of hesitants (any number) as in this example
* H1={2,3}
* H2={1,2,3}
* Params: lamda. When =1 it compute the Hamming distance. When =2 is the Euclidean distance
*, granularity, for instance G=6,
* Xhi
* Out: d_(H1,H2) = distance in real
* Requirements: it has to work with hesitant of the same length L
*/
function euclideanDistance($H1, $H2, $lambda, $G, $X)
{
$size = [sizeof($H1), sizeof($H2)];
$L = max($size);
$exp = $lambda;
$den = $G + 1;
/* {
echo('<br>H1 <pre>'); print_r($H1); echo('</pre>');
echo('<br>H2 <pre>'); print_r($H2); echo('</pre>');
}*/
if ($size[0] == $size[1]) {
$EH1 = extend($H1, 0, $G, $X);
$EH2 = extend($H2, 0, $G, $X);
} else {
if ($size[0] < $size[1]) {
$EH1 = extend($H1, $size[1] - $size[0], $G, $X);
$EH2 = extend($H2, 0, $G, $X);
//system_message(" extend H1 " . ($size[1]-$size[0])) ;
} else {
if ($size[0] > $size[1]) {
$EH1 = extend($H1, 0, $G, $X);
$EH2 = extend($H2, $size[0] - $size[1], $G, $X);
//system_message(" extend H2 " . ($size[0]-$size[1])) ;
}
}
}
$sum = 0;
for ($g = 0; $g < $L; $g++) {
$d_abs = abs($EH1[$g] - $EH2[$g]);
$fracc2 = pow($d_abs / $den, $exp);
$sum += $fracc2;
//echo "<br>d_abs=".$d_abs." frac=".$fracc2." ";
}
$exp = 1.0 / $lambda;
$sumL = $sum / $L;
$d = pow($sumL, $exp);
//echo "<br>sumL=".$sumL." exp=".$exp." distance=".$d;
return $d;
}
开发者ID:rosanamontes,项目名称:teranga.go,代码行数:51,代码来源:mcdm.php
示例8: extend
/**
* Merges properties from a source object (or array) into a target object.
*
* <p>Assignments are recursive.
* <p>If the target property is an object implementing ArrayAccess, the assignment is performed via `[]`, otherwise it's
* performed via `->`.
*
* @param object $target
* @param object|array $src
* @throws InvalidArgumentException If any of the arguments is not of one of the expected types.
*/
function extend($target, $src)
{
$c = $target instanceof ArrayAccess;
if (isset($src)) {
if (is_iterable($src)) {
if (is_object($target)) {
foreach ($src as $k => $v) {
// iterates both objects and arrays
if (isset($target->{$k}) && (is_array($v) || is_object($v))) {
if (is_object($target->{$k})) {
extend($target->{$k}, $v);
} elseif (is_array($target->{$k})) {
array_recursiveMergeInto($target->{$k}, $v);
} elseif ($c) {
$target[$k] = $v;
} else {
$target->{$k} = $v;
}
} elseif ($c) {
$target[$k] = $v;
} else {
$target->{$k} = $v;
}
}
} else {
throw new InvalidArgumentException('Invalid target argument');
}
} else {
throw new InvalidArgumentException('Invalid source argument');
}
}
}
开发者ID:php-kit,项目名称:tools,代码行数:43,代码来源:objects.php
示例9: extend
<? extend('error', 'frix/error') ?>
开发者ID:ricobl,项目名称:frix,代码行数:1,代码来源:http_500.php
示例10: explode
{
$extend = explode(".", $file_name);
$va = count($extend) - 1;
return strtolower($extend[$va]);
}
$dirname = "../";
//是否启用上一层路径,格式为:$dirname="../";或$dirname="../../";等等与$dir组合使用,注意不要溢出根路径
$dir = 'upload/aa/bb';
//设定上传目录,与上面的$dirname组合
$file = $_FILES['file'];
//从文件域表单获取文件
$filename = $file['name'];
//获取文件全名
$c_filesize = $file['size'];
//获取本地的文件大小
$extendname = extend($filename);
//获取文件扩展名
if ($c_filesize > 200000000000) {
die("文件太大");
}
//限制上传文件大小, 单位字节
if (!file_exists($dir)) {
}
$v = split('[/.-]', $dir);
for ($i = 0; $i < count($v); $i++) {
$dirname = $dirname . $v[$i];
if (!file_exists($dirname)) {
mkdir($dirname);
}
$dirname = $dirname . "/";
}
开发者ID:doit05,项目名称:relProject,代码行数:31,代码来源:value_report.php
示例11: extend
<?php
extend('layout.php');
?>
<?php
startblock('title');
?>
View Location
<?php
endblock();
?>
<?php
startblock('css');
?>
<?php
echo get_extended_block();
endblock();
?>
<?php
startblock('js');
?>
q
<?php
echo get_extended_block();
?>
<script>
$( document ).ready(function(){
$('#menu_place').addClass('active');
开发者ID:kostya1017,项目名称:our,代码行数:31,代码来源:list_owner-old.php
示例12: array
<?php
$path = "uploads/";
$extArr = array("jpg", "png", "gif");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
if(empty($name)){
echo '请选择要上传的图片';
exit;
}
$ext = extend($name);
if(!in_array($ext,$extArr)){
echo '图片格式错误!';
exit;
}
if($size>(100*1024)){
echo '图片大小不能超过100KB';
exit;
}
$image_name = time().rand(100,999).".".$ext;
$tmp = $_FILES['photoimg']['tmp_name'];
if(move_uploaded_file($tmp, $path.$image_name)){
echo '<img src="'.$path.$image_name.'" class="preview">';
}else{
echo '上传出错了!';
}
exit;
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:31,代码来源:upload.php
示例13: extend
<? extend('base') ?>
<? block('contents') ?>
<h2>Error <?php
echo $error_code;
?>
</h2>
<div id="text_box">
<p><?php
echo $error_msg;
?>
</p>
<p>Please contact the administrator.</p>
</div>
<? end_block() ?>
开发者ID:ricobl,项目名称:frix,代码行数:16,代码来源:error.php
示例14: extend
<? extend('frix/admin/splash') ?>
<? block('contents') ?>
<form action="<?php
echo $_SERVER['REQUEST_URI'];
?>
" method="post" enctype="multipart/form-data">
<?php
echo $form->render_fields();
?>
<p class="buttons">
<input type="submit" class="button" name="submit" value="OK" />
</p>
</form>
<p><a href="forgot/">Forgot Password?</a></p>
<? end_block() ?>
开发者ID:ricobl,项目名称:frix,代码行数:19,代码来源:login.php
示例15: merge
function merge(array $data = null)
{
if (is_null($data) || is_null($this->model)) {
return;
}
$data = array_normalizeEmptyValues($data, true);
if (is_array($this->model)) {
array_recursiveMergeInto($this->model, $data);
} else {
if (is_object($this->model)) {
extend($this->model, $data);
} else {
throw new FatalException(sprintf("Can't merge data into a model of type <kbd>%s</kbd>", gettype($this->model)));
}
}
}
开发者ID:electro-framework,项目名称:framework,代码行数:16,代码来源:AbstractModelController.php
示例16: extend
<? extend('frix/admin/base') ?>
<? block('contents') ?>
<div id="message">
<p>Are you sure you want to delete <strong>"<?php
echo $file_name;
?>
"</strong>?</p>
</div>
<form action="./?<?php
echo $_SERVER['QUERY_STRING'];
?>
" method="post">
<p class="buttons">
<span class="button"><input type="submit" name="delete" value="Yes" /></span>
<span class="button"><a href="./">No</a></span>
</p>
</form>
<? end_block() ?>
开发者ID:ricobl,项目名称:frix,代码行数:20,代码来源:delete.php
示例17: extend
开发者ID:ricobl,项目名称:frix,代码行数:1,代码来源:page.php
示例18: _initialize
protected function _initialize()
{
header("Content-type: text/html; charset=utf-8");
/*
if(!isMobile()){
//header("location:".C('WEB_PC_URL'));
}*/
//网站配置
$SiteConfigData = S('SITE_CONFIG_DATA');
if (!$SiteConfigData) {
$data = M('Config')->where(array('group' => 1))->select();
$arr = array();
foreach ($data as $key => $value) {
$arr[$value['keys']] = $value['value'];
}
S('SITE_CONFIG_DATA', $arr, C('APP_S_CACHE_TIME'));
$SiteConfigData = $arr;
}
//缓存 城市列表 品牌 车系
$SiteCityData = S('SITE_CITY_DATA');
if (!$SiteCityData) {
$data = M('City')->order('sort desc,id asc')->select();
S('SITE_CITY_DATA', $data, C('APP_S_CACHE_TIME'));
$SiteCityData = $data;
foreach ($data as $key => $value) {
$brand = array();
$series = array();
$carList = M('Car')->where('status in (1,2) and city_id =' . $value['id'])->field('brand_id,series_id,city_id')->select();
foreach ($carList as $k => $v) {
$brand[] = $v['brand_id'];
$series[] = $v['series_id'];
}
S('SITE_CAR_BRAND_' . $value['id'], $brand, C('APP_S_CACHE_TIME'));
S('SITE_CAR_SERIES_' . $value['id'], $series, C('APP_S_CACHE_TIME'));
}
}
//缓存 店铺 品牌 车系
$SiteStoreData = S('SITE_STORE_DATA');
if (!$SiteStoreData) {
$data = M('Store')->order('sort desc,id asc')->select();
S('SITE_STORE_DATA', $data, C('APP_S_CACHE_TIME'));
$SiteStoreData = $data;
foreach ($data as $key => $value) {
$brand = array();
$series = array();
$carList = M('Car')->where('status in (1,2) and store_id =' . $value['id'])->field('brand_id,series_id,store_id')->select();
foreach ($carList as $k => $v) {
$brand[] = $v['brand_id'];
$series[] = $v['series_id'];
}
S('SITE_CAR_BRAND_STORE_' . $value['id'], $brand, C('APP_S_CACHE_TIME'));
S('SITE_CAR_SERIES_STORE_' . $value['id'], $series, C('APP_S_CACHE_TIME'));
}
}
//获取当前城市
$subDomian = extend($_SERVER['HTTP_HOST']);
$cookiewebcity = cookie('webcity');
$sessionwebcity = session('webcity');
$webCity = empty($cookiewebcity) ? $sessionwebcity : $cookiewebcity;
session('webcity', $webCity);
if (!empty($_GET['city']) || !empty($_GET['store'])) {
if ($_GET['city'] == 'all') {
session('webcity', null);
session('webstore', null);
cookie('webcity', null);
} else {
$city = M('City')->field('id,title,pinyin')->where('id = ' . $_GET['city'])->find();
$store = M('Store')->field('id,title')->where('id = ' . $_GET['store'])->find();
$city ? session('webcity', $city) : session('webcity', null);
$store ? session('webstore', $store) : session('webstore', null);
$city ? cookie('webcity', $city) : cookie('webcity', null);
}
} else {
if (!isset($webCity)) {
$ipData = curl_get_contents(C('IP_LOCATION_URL') . get_client_ip());
$city = json_decode($ipData, true);
//$data = M('City')->field('id,title,pinyin')->where(array( 'title'=> $city['city'] ))->find();
$data = M('City')->field('id,title,pinyin')->where(array('title' => '深圳'))->find();
$data ? session('webcity', $data) : session('webcity', null);
$data ? cookie('webcity', $data) : cookie('webcity', null);
}
}
$this->assign(array('SiteConfigData' => $SiteConfigData, 'SiteCityData' => $SiteCityData, 'SiteCurentCity' => session('webcity')));
}
开发者ID:Ajh100,项目名称:mobile,代码行数:84,代码来源:BaseController.class.php
示例19: _initialize
protected function _initialize()
{
header("Content-type: text/html; charset=utf-8");
if (isMobile()) {
header("location:" . C('WEB_MOBILE_URL'));
}
//网站配置
$SiteConfigData = S('SITE_CONFIG_DATA');
if (!$SiteConfigData) {
$data = M('Config')->where(array('group' => 1))->select();
$arr = array();
foreach ($data as $key => $value) {
$arr[$value['keys']] = $value['value'];
}
S('SITE_CONFIG_DATA', $arr, C('APP_S_CACHE_TIME'));
$SiteConfigData = $arr;
}
//缓存 城市列表 品牌 车系
$SiteCityData = S('SITE_CITY_DATA');
if (!$SiteCityData) {
$data = M('City')->where('status = 0')->order('sort desc,id asc')->select();
S('SITE_CITY_DATA', $data, C('APP_S_CACHE_TIME'));
$SiteCityData = $data;
$CAR_BRAND_LIST = S('CAR_BRAND_LIST');
if (!$CAR_BRAND_LIST) {
$carList = M('Car')->where('status in (1,2)')->field('brand_id,series_id,city_id')->select();
foreach ($carList as $k => $v) {
$brand[] = $v['brand_id'];
$series[] = $v['series_id'];
}
S('SITE_CAR_BRAND', $brand, C('APP_S_CACHE_TIME'));
S('SITE_CAR_SERIES', $series, C('APP_S_CACHE_TIME'));
S('CAR_BRAND_LIST', $carList, C('APP_S_CACHE_TIME'));
$CAR_BRAND_LIST = $carList;
}
foreach ($data as $key => $value) {
$brand = array();
$series = array();
$carList = M('Car')->where('status in (1,2) and city_id =' . $value['id'])->field('brand_id,series_id,city_id')->select();
foreach ($carList as $k => $v) {
$brand[] = $v['brand_id'];
$series[] = $v['series_id'];
}
S('SITE_CAR_BRAND_' . $value['id'], $brand, C('APP_S_CACHE_TIME'));
S('SITE_CAR_SERIES_' . $value['id'], $series, C('APP_S_CACHE_TIME'));
}
}
//获取当前城市
$subDomian = extend($_SERVER['HTTP_HOST']);
$cookiewebcity = cookie('webcity');
$sessionwebcity = session('webcity');
$webCity = empty($cookiewebcity) ? $sessionwebcity : $cookiewebcity;
session('webcity', $webCity);
if ($subDomian == 'www') {
if (!$webCity) {
$ipData = curl_get_contents(C('IP_LOCATION_URL') . get_client_ip());
$city = json_decode($ipData, true);
$data = M('City')->field('id,title,pinyin')->where(array('title' => $city['city']))->find();
$data ? session('webcity', $data) : session('webcity', array());
$data ? cookie('webcity', $data) : cookie('webcity', array());
}
} else {
$data = M('City')->field('id,title,pinyin')->where(array('pinyin' => $subDomian))->find();
$data ? session('webcity', $data) : session('webcity', array());
$data ? cookie('webcity', $data) : cookie('webcity', array());
}
//友情链接
$friendLink = S('Friend_Link');
if (!$friendLink) {
$friendLink = M('Link')->where(array('status' => 0, 'is_read' => 1))->order('sort desc')->limit(10)->select();
S('Friend_Link', $friendLink, C('APP_S_CACHE_TIME'));
}
$this->assign(array('SiteConfigData' => $SiteConfigData, 'SiteCityData' => $SiteCityData, 'SiteCurentCity' => session('webcity'), 'friendLink' => $friendLink));
}
开发者ID:Ajh100,项目名称:portal,代码行数:74,代码来源:BaseController.class.php
示例20: extend
<?php
extend('layouts/frontend', ['title' => 'Homepage']);
?>
<style type="text/css">
body {
background: #1C2126;
text-align: center;
}
img {
margin-top: 15%;
}
.quote {
text-align: center;
color: #ff2469;
font-size: 20px;
text-shadow: 0 2px 3px #000000
}
.quote small {
font-size: 14px;
color: #cccccc;
}
center {
font-size: 11px;
position: fixed;
bottom: 20px;
开发者ID:knyteblayde,项目名称:strife,代码行数:31,代码来源:index.php
注:本文中的extend函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论