本文整理汇总了PHP中extend函数的典型用法代码示例。如果您正苦于以下问题:PHP extend函数的具体用法?PHP extend怎么用?PHP extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
示例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();
}
示例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;
}
}
}
示例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;
}
示例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');
}
}
}
示例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 . "/";
}
示例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');
示例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;
}
示例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() ?>
示例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() ?>
示例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)));
}
}
}