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


PHP Func类代码示例

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


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

示例1: getGlobalConstructor

 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $Buffer = new Func('Buffer', function () {
         $self = new Buffer();
         $self->init(func_get_args());
         return $self;
     });
     $Buffer->set('prototype', Buffer::$protoObject);
     $Buffer->setMethods(Buffer::$classMethods, true, false, true);
     return $Buffer;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:15,代码来源:Buffer.php

示例2: getGlobalConstructor

 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $Error = new Func(function ($str = null) {
         $error = new self($str);
         $error->stack = debug_backtrace();
         return $error;
     });
     $Error->set('prototype', self::$protoObject);
     $Error->setMethods(self::$classMethods, true, false, true);
     return $Error;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:15,代码来源:Error.php

示例3: shouldWriteReturnType

 /**
  * @param Func $function
  * @param bool $hack
  *
  * @return bool
  */
 private function shouldWriteReturnType(Func $function, $hack)
 {
     $name = $function->getReflection()->getName();
     if ($function->getReflection() instanceof \ReflectionMethod && in_array($name, ['__construct', '__destruct', '__clone'])) {
         return false;
     }
     $comment = $function->getReturnComment();
     if (!$comment) {
         return false;
     }
     return $comment->getType() && $comment->getType()->getDeclaration($hack);
 }
开发者ID:dchesterton,项目名称:phpdoc-to-return,代码行数:18,代码来源:Converter.php

示例4: read

 /**
  * @param Func $function
  * @return SignatureData[]
  */
 public function read(Func $function)
 {
     $params = array();
     foreach ($function->reflection()->getParameters() as $param) {
         $data = new SignatureData();
         $data->name = $param->getName();
         $data->type = $this->getType($param);
         $data->default = $this->getDefault($param);
         $data->hasDefault = $param->isOptional();
         $params[] = $data;
     }
     return $params;
 }
开发者ID:rawebone,项目名称:injector,代码行数:17,代码来源:SignatureReader.php

示例5: update

 /** загрузка(сохранение/обновление) аватара
  * @param integer ID записи
  * @param boolean удалять предыдущий аватар
  * @return имя файла успешно загруженной аватары | false
  */
 function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false)
 {
     global $oDb;
     if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) {
         $oUpload = new Upload($this->input, false);
         $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']);
         if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             if ($bDeletePrevious) {
                 $this->delete($nRecordID, false);
             }
             $sExtension = func::image_type_to_extension($aImageSize[2], false);
             $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension;
             //проверяем размер файла
             if (!$oUpload->checkSize($this->maxsize)) {
                 return false;
             }
             //создаем thumbnail
             $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']);
             $oThumb->jpeg_quality(85);
             $oThumb->crop_proportionaly(1, 1, 'middle', 'center');
             $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $sFilename, $this->width, $this->height, true);
             @unlink($_FILES[$this->input]['tmp_name']);
             if ($bDoUpdateQuery) {
                 $oDb->execute("UPDATE {$this->table} \n                                   SET {$this->fieldAvatar} =" . $oDb->str2sql($sFilename) . "\n                                   WHERE {$this->fieldID} = {$nRecordID} ");
             }
             return $sFilename;
         }
     }
     return false;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:35,代码来源:avatar.php

示例6: signUp

 public static function signUp(array $data)
 {
     if (!$data) {
         return false;
     }
     if (!isset($data['last_login_time'])) {
         $data['last_login_time'] = time();
     }
     if (!isset($data['last_login_ip'])) {
         $data['last_login_ip'] = Func::getIP();
     }
     if (!isset($data['login_time'])) {
         $data['login_time'] = time();
     }
     if (!isset($data['login_ip'])) {
         $data['login_ip'] = Func::getIP();
     }
     if (!isset($data['create_time'])) {
         $data['create_time'] = time();
     }
     $data['login_count'] = 1;
     $data['user_code'] = self::getNewUserCode();
     $insertid = 0;
     DB::tranBegin();
     $insertid = self::insert($data);
     DB::tranEnd();
     return $insertid;
 }
开发者ID:isonz,项目名称:fxptpcn,代码行数:28,代码来源:Users.class.php

示例7: basicAction

 /**
  * 合作机构基本信息
  */
 public function basicAction($uni_id)
 {
     //判断是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['union_logo'] = $validate->getPost('union_logo');
         //机构logo
         $data['union_name'] = $validate->getPost('union_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
         //机构名称
         //验证参数
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成机构logo,缩略图
         if ($data['union_logo']) {
             $data['union_logo'] = \Func::touchImg($data['union_logo'], 'union_logo');
             //监测图片是否生成成功
             if (!$data['union_logo']) {
                 \FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['union_logo']);
                 $this->end(400);
             }
         }
         $this->end((new \Union())->updUnionBasic($this->session->get('id'), $uni_id, $data));
     }
     //机构id
     $uni_id = (int) $uni_id;
     //获取基本数据
     $basic = (new \Union())->getUnionBasic($uni_id);
     //加载js
     $this->assets->addJs('backend/mt-js/union.js');
     $this->view->setVars(['uni_id' => $uni_id, 'basic' => $basic]);
 }
开发者ID:xw716825,项目名称:git_back,代码行数:35,代码来源:UnionController.php

示例8: newAction

 /**
  * 新增属性
  */
 public function newAction()
 {
     //检查是否是ajax请求
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['att_img'] = $validate->getPost('att_img', \Validate::base64());
         //属性图
         $data['att_name'] = $validate->getPost('att_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
         //属性名称
         $data['att_sort'] = $validate->getPost('att_sort', \Validate::int());
         //排序
         //验证数据
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成学校logo,缩略图
         $data['att_img'] = \Func::touchImg($data['att_img'], 'att_img');
         //将生成的图片地址存入img,用户失败时删除
         $img = [UPLOAD_PATH . $data['att_img'], UPLOAD_PATH . $data['att_img']];
         //监测图片是否全部生成成功
         if (!$data['att_img']) {
             \FileUtil::getInstance()->unlink($img);
         }
         //新增高校
         $result = (new \Attribute())->addAttribute($this->session->get('id'), $data);
         if ($result != 200) {
             \FileUtil::getInstance()->unlink($img);
         }
         $this->end($result);
     }
     //加载所需js
     $this->assets->addJs('backend/mt-js/attribute-new.js');
 }
开发者ID:xw716825,项目名称:git_back,代码行数:36,代码来源:AttributeController.php

示例9: init

 public function init()
 {
     Yii::app()->user->opt_id = time() . rand(10000, 99999);
     Yii::app()->user->logNotice = array();
     Func::validateURL();
     $this->request = Yii::app()->request;
 }
开发者ID:wheatma,项目名称:react_study,代码行数:7,代码来源:Controller.php

示例10: smarty_modifier_dateleft

/**
 * Smarty dateleft modifier plugin
 *
 * Type:     modifier<br>
 * Name:     dateleft<br>
 * Purpose:  dateleft
 * @author battazo
 * @param string
 * @param string
 * @param interger
 * @param interger
 * @param string                   
 * @param string
 */
function smarty_modifier_dateleft($sDatetime, $getTime = false)
{
    //get datetime
    if (!$sDatetime) {
        return false;
    }
    $date = Func::parse_datetime($sDatetime);
    //    function dateDiff($dformat, $endDate, $beginDate)
    //    {
    //        $date_parts1 = explode($dformat, $beginDate);
    //        $date_parts2 = explode($dformat, $endDate);
    //        $start_date  = gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
    //        $end_date    = gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
    //        return $end_date - $start_date;
    //    }
    //    $date1="07/11/2003";
    //    $date2="09/04/2004";
    //    print "If we minus " . $date1 . " from " . $date2 . " we get " . dateDiff("/", $date2, $date1) . ".";
    //    If we minus 07/11/2003 from 09/04/2004 we get 421.
    //$dob="08/12/1975";
    //echo "If you were born on " . $dob . ", then today your age is approximately " .
    //round(dateDiff("/", date("m/d/Y", time()), $dob)/365, 0) . " years.";
    //If you were born on 08/12/1975, then today your age is approximately 30 years.
    smarty_modifier_datespent($sDatetime, $getTime);
}
开发者ID:Sywooch,项目名称:dobox,代码行数:39,代码来源:modifier.dateleft.php

示例11: edit

 /**
  * @descrpition 修改
  */
 public function edit()
 {
     if (Request::getRequest('dosubmit', 'str')) {
         $jumpUrl = '/admin.php/itemdocmenu/edit/id-' . $this->param['id'];
         $fields = array();
         $fields['name'] = Request::getRequest('name', 'str');
         $fields['pid'] = Request::getRequest('pid', 'str');
         $fields['in_out'] = Request::getRequest('in_out', 'str');
         $fields['url'] = Request::getRequest('url', 'str');
         $fields['item'] = strtolower(Request::getRequest('item', 'item'));
         if (empty($fields['name']) || empty($fields['item'])) {
             View::showAdminErrorMessage($jumpUrl, '未填写完成');
         }
         $result = ItemDocMenuBusiness::editMenu($this->param['id'], $fields);
         if ($result) {
             View::showAdminMessage('/admin.php/itemdocmenu/lists', '修改成功');
         } else {
             View::showAdminErrorMessage($jumpUrl, '修改失败');
         }
     }
     $menuList = ItemDocMenuBusiness::getMenuList();
     $menuList = Func::arrayKey($menuList);
     $blogMenuList = Func::categoryTree($menuList);
     $blogMenu = ItemDocMenuBusiness::getMenu($this->param['id']);
     View::assign('blogMenu', $blogMenu);
     View::assign('blogMenuList', $blogMenuList);
     View::showAdminTpl('item_doc_menu_edit');
 }
开发者ID:web5,项目名称:LX_Blog,代码行数:31,代码来源:itemdocmenu.php

示例12: backup

 /**
  * 数据库备份
  */
 public function backup()
 {
     set_time_limit(0);
     $data = array();
     if ($_POST) {
         $backup_dir = BASEPATH . '../cache/backup/';
         if (!is_dir($backup_dir)) {
             mkdir($backup_dir, '0777', true);
         }
         include dirname(__FILE__) . '/../../config/config.db.php';
         $cfg = $db[$db['active_group']];
         $is_export_student = intval($this->input->post('is_export_student'));
         $sql_file = DbmanageModel::backupTables($cfg['database'], $backup_dir, array('*'), $is_export_student);
         if (file_exists($backup_dir . $sql_file)) {
             require_once APPPATH . 'libraries/Pclzip.php';
             $save_file = $backup_dir . "/zmte_database.zip";
             if (is_file($save_file)) {
                 @unlink($save_file);
             }
             $archive = new PclZip($save_file);
             //将文件进行压缩
             $archive->create($backup_dir . $sql_file, PCLZIP_OPT_REMOVE_ALL_PATH);
             @unlink($backup_dir . $sql_file);
             Func::dumpFile('application/zip', $save_file, 'zmte_database_' . date('YmdHis') . '.zip');
             @unlink($save_file);
             redirect('/admin/dbmanage/backup');
         } else {
             message('数据库备份失败,请稍后重试!');
         }
     } else {
         $this->load->view('dbmanage/backup', $data);
     }
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:36,代码来源:dbmanage.php

示例13: addAction

 /**
  * 回答接口
  */
 public function addAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'empty_ans_id', 'mem_relation_id', 'que_id', 'ans_content', 'is_img', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //判断是否是图片
     if ($this->data['is_img'] == 1) {
         $this->data['ans_content'] = \Func::touchImg($this->data['ans_content'], 'ans');
         if (!$this->data['ans_content']) {
             $this->throwMessage(ILLEGAL_IMAGE);
         }
     }
     //默认执行回答提问方法
     $func = 'addAnswer';
     //需要的字段
     $field = ['mem_id', 'mem_mark', 'mem_relation_id', 'que_id', 'ans_content'];
     //根据可空回答id,empty_ans_id判断是否执行追问方法
     if ($this->data['empty_ans_id']) {
         array_push($field, $this->data['empty_ans_id']);
         $func = 'addAnswerAsk';
     }
     //转义回答内容
     $this->data['ans_content'] = mb_substr(\Func::escape($this->data['ans_content']), 0, 250, 'utf-8');
     //获取执行状态,执行失败,并且是图片信息,则删除上传的图片
     $add_status = $this->callModelFunc('Answer', $func, $field);
     if ($add_status != OK && $this->data['is_img'] == 1) {
         \FileUtil::getInstance()->unlink(PUBLIC_PATH . $this->data['ans_content']);
     }
     $this->throwMessage($add_status);
 }
开发者ID:xw716825,项目名称:work,代码行数:33,代码来源:AnswerController.php

示例14: toTable

 /** @return Table */
 function toTable()
 {
     $zcoeffs = array();
     foreach ($this->function->getSet() as $var => $coeff) {
         $zcoeffs[$var] = $coeff->multiply(-1);
     }
     $z = new ValueFunc($zcoeffs, 0);
     $z2b = Fraction::create(0);
     $z2coeffs = array();
     foreach ($this->restrictions as $idx => $r) {
         foreach ($r->getSet() as $var => $coeff) {
             if (strncmp($var, 'y', 1) === 0 && $coeff->isEqualTo(1)) {
                 foreach ($r->getSet() as $v => $c) {
                     !isset($z2coeffs[$v]) && ($z2coeffs[$v] = Fraction::create(0));
                     strncmp($v, 'y', 1) !== 0 && ($z2coeffs[$v] = $z2coeffs[$v]->subtract($c));
                 }
                 $z2b = $z2b->subtract($r->getLimit());
             }
         }
     }
     $z2 = count($z2coeffs) ? new ValueFunc($z2coeffs, $z2b) : NULL;
     $table = new Table($z, $z2);
     foreach ($this->basismap as $var => $idx) {
         $table->addRow(new TableRow($var, $this->restrictions[$idx]->getSet(), $this->restrictions[$idx]->getLimit()));
     }
     return $table;
 }
开发者ID:uestla,项目名称:simplex-calculator,代码行数:28,代码来源:Task.php

示例15: init

 function init()
 {
     $errno = strip_tags(Func::GETPOST('errno'));
     if ($errno) {
         $this->set($errno);
         $this->sm->assign('errno', $errno);
     }
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:8,代码来源:errors.php


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