• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP underscore函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: tabs

function tabs($tabs, $position = 'left', $active = FALSE, $id_prefix = '')
{
    if (!$tabs) {
        return '';
    }
    if (!is_array($tabs)) {
        return $tabs;
    }
    $menu = '<ul class="nav nav-tabs">';
    $content = '<div class="tab-content">';
    foreach ($tabs as $name => $tab) {
        if ($tab) {
            $name = strtolower(underscore($name));
            $menu .= '<li';
            $content .= '<div id="' . $id_prefix . $name . '" class="tab-pane';
            if ($active === FALSE || $active === $name) {
                $menu .= ' class="active"';
                $content .= ' active';
                $active = TRUE;
            }
            $menu .= '><a href="#' . $id_prefix . $name . '" data-toggle="tab" class="no-ajax">' . humanize(preg_replace('/tab(\\d)+_/i', '', $name)) . '</a></li>';
            $content .= '">' . $tab . '</div>';
        }
    }
    $menu .= '</ul>';
    $content .= '</div>';
    return '<div class="tabbable tabs-' . $position . '">' . ($position != 'below' ? $menu . $content : $content . $menu) . '</div>';
}
开发者ID:jayalfredprufrock,项目名称:winx,代码行数:28,代码来源:bootstrap_helper.php


示例2: chain

 public function chain($item = null)
 {
     list($item) = self::_wrapArgs(func_get_args(), 1);
     $__ = isset($this) && isset($this->_chained) && $this->_chained ? $this : underscore($item);
     $__->_chained = true;
     return $__;
 }
开发者ID:websublime,项目名称:pressly,代码行数:7,代码来源:underscore.php


示例3: test_underscore

 public function test_underscore()
 {
     $strs = array('this is the string' => 'this_is_the_string', 'this is another one' => 'this_is_another_one', 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'what_do_you_think-yo?');
     foreach ($strs as $str => $expect) {
         $this->assertEquals($expect, underscore($str));
     }
 }
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:7,代码来源:inflector_helper_test.php


示例4: generate

 /**
  * Generates set of code based on data.
  *
  * @return array
  */
 public function generate()
 {
     $this->prepareData($this->data);
     $columnFields = ['name', 'description', 'label'];
     $table = $this->describe->getTable($this->data['name']);
     foreach ($table as $column) {
         if ($column->isAutoIncrement()) {
             continue;
         }
         $field = strtolower($column->getField());
         $method = 'set_' . $field;
         $this->data['camel'][$field] = lcfirst(camelize($method));
         $this->data['underscore'][$field] = underscore($method);
         array_push($this->data['columns'], $field);
         if ($column->isForeignKey()) {
             $referencedTable = Tools::stripTableSchema($column->getReferencedTable());
             $this->data['foreignKeys'][$field] = $referencedTable;
             array_push($this->data['models'], $referencedTable);
             $dropdown = ['list' => plural($referencedTable), 'table' => $referencedTable, 'field' => $field];
             if (!in_array($field, $columnFields)) {
                 $field = $this->describe->getPrimaryKey($referencedTable);
                 $dropdown['field'] = $field;
             }
             array_push($this->data['dropdowns'], $dropdown);
         }
     }
     return $this->data;
 }
开发者ID:rougin,项目名称:combustor,代码行数:33,代码来源:ControllerGenerator.php


示例5: define

 /**
  * Model definition.
  */
 function define()
 {
     // Fields.
     $this->fields = array('id', 'slug', 'name', 'fields', 'inputs', 'subscribers', 'date_created', 'date_updated', 'fields' => function ($channel) {
         return orderby($channel['fields'], 'sort');
     }, 'fields_by_id' => function ($channel) {
         return Channels::get_fields_by_id($channel);
     }, 'entries' => function ($channel) {
         return get("/entries", array('channel_id' => $channel['id']));
     }, 'entry_count' => function ($channel) {
         return get("/entries/:count", array('channel_id' => $channel['id']));
     });
     $this->search_fields = array('name');
     // Indexes.
     $this->indexes = array('id' => 'unique', 'slug' => 'unique');
     // Query defaults.
     $this->query = array('order' => 'name ASC');
     // Validate.
     $this->validate = array('required' => array('name', 'slug'), 'unique' => array('slug'), ':fields' => array('required' => array('id', 'name', 'type'), 'unique' => array('id')));
     // Event binds.
     $this->binds = array('POST' => function ($event) {
         $data =& $event['data'];
         // Auto slug?
         if ($data['name'] && !$data['slug']) {
             $data['slug'] = hyphenate($data['name']);
         }
     }, 'POST.fields' => function ($event) {
         $data =& $event['data'];
         // Default field ID to underscored field name.
         if (isset($data['name']) && !$data['id']) {
             $data['id'] = underscore($data['name']);
         }
     });
 }
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:37,代码来源:Channels.php


示例6: transformField

 /**
  * Transforms the field into the template.
  *
  * @param  string $field
  * @param  string $type
  * @return array
  */
 protected function transformField($field, $type)
 {
     if ($type == 'camelize') {
         return ['field' => lcfirst(camelize($field)), 'accessor' => lcfirst(camelize('get_' . $field)), 'mutator' => lcfirst(camelize('set_' . $field))];
     }
     return ['field' => lcfirst(underscore($field)), 'accessor' => lcfirst(underscore('get_' . $field)), 'mutator' => lcfirst(underscore('set_' . $field))];
 }
开发者ID:rougin,项目名称:combustor,代码行数:14,代码来源:BaseGenerator.php


示例7: collectionName

 public function collectionName()
 {
     if ($this->_ns) {
         return substr($this->_ns, strpos($this->_ns, '.') + 1);
     }
     $name = str_replace('\\', '_', underscore(get_called_class()));
     return preg_replace('/_model/', '', $name, 1);
 }
开发者ID:tany,项目名称:php-note,代码行数:8,代码来源:Model.php


示例8: testCanWrapWithShortcutFunction

 public function testCanWrapWithShortcutFunction()
 {
     // Skip if base function not present
     if (!function_exists('underscore')) {
         return $this->assertTrue(true);
     }
     $under = underscore($this->array);
     $this->assertInstanceOf('Underscore\\Underscore', $under);
 }
开发者ID:arizawan,项目名称:livetvwithyoutube,代码行数:9,代码来源:UnderscoreTest.php


示例9: update

 public function update($fields)
 {
     $fields['group_key'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['group_title'])));
     $update_item = parent::update($fields);
     // Everytime you update a group, let's publish it.
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
开发者ID:vsa-partners,项目名称:typologycms,代码行数:9,代码来源:page_attributegroup_model.php


示例10: render_template

 /**
  * Fetches the default template for an action of this controller.  It calculates
  * the file location, loads it into smarty and returns the results.
  *
  * @param string The name of the action to display the view of
  * @param array An array of parameters to send to the template.  This generally come
  *        from the route processor.
  * @return The rendered result
  * @author Ted Kulp
  **/
 function render_template($action_name, $params = array())
 {
     $default_template_dir = str_replace('_controller', '', underscore(get_class($this)));
     $path_to_default_template = join_path($this->get_component_directory(), 'views', $default_template_dir, underscore($action_name) . '.tpl');
     if (is_file($path_to_default_template)) {
         return smarty()->fetch("file:{$path_to_default_template}");
     } else {
         throw new SilkViewNotFoundException();
     }
 }
开发者ID:JackSpratt,项目名称:silk,代码行数:20,代码来源:class.silk_controller_base.php


示例11: setLabel

 /**
  *
  */
 public function setLabel($label)
 {
     if (!is_string($label)) {
         throw new \InvalidArgumentException();
     }
     $this->label = $label;
     if (empty($this->name)) {
         $this->name = underscore($label, '-');
     }
 }
开发者ID:jellybeansoup,项目名称:php-ui,代码行数:13,代码来源:Field.php


示例12: downloadStudentResult

 function downloadStudentResult($class_id, $topic_manage_id)
 {
     $this->CI->load->model('student_info_model');
     $this->CI->load->model('class_model');
     $this->CI->load->model('topic_model');
     $this->CI->load->model('student_mark_model');
     $this->CI->load->helper('inflector');
     $this->CI->load->library(['utils']);
     $class = $this->CI->class_model->find_by_pkey($class_id);
     $topic = $this->CI->topic_model->getTopicIdByTopicManageId($topic_manage_id);
     $topics = array_filter(array_map('trim', explode(',', $topic->topic_id)));
     $studentsMark = $this->CI->student_mark_model->getMarkStudents($topics, $class_id);
     $studentsMark = $this->CI->utils->makeList('student_id', $studentsMark);
     $students = $this->CI->student_info_model->getAllStudents($class_id);
     $this->CI->load->library('PhpOffice/PHPExcel');
     $sheet = $this->CI->phpexcel->getActiveSheet();
     $title_class = underscore($class->class_name) . '.xls';
     $row = 1;
     // header
     $sheet->setCellValue('A' . $row, 'STT');
     $sheet->setCellValue('B' . $row, 'Họ tên');
     $sheet->setCellValue('C' . $row, 'Điểm');
     $sheet->setCellValue('D' . $row, 'Ghi chú');
     $sheet->setCellValue('E' . $row, 'IP');
     $listIndentities = array();
     $ipList = array();
     foreach ($students as $key => $student) {
         ++$row;
         $sheet->setCellValue("A{$row}", $student->indentity_number);
         $sheet->setCellValue("B{$row}", $student->fullname);
         if (isset($studentsMark[$student->student_id])) {
             $resultOfStudent = $studentsMark[$student->student_id];
             if (!empty($resultOfStudent->ip_address) && in_array($resultOfStudent->ip_address, $ipList)) {
                 $sheet->setCellValue("D{$row}", "Trùng địa chỉ IP");
             } else {
                 $sheet->setCellValue("D{$row}", "");
                 $ipList[] = $resultOfStudent->ip_address;
             }
             $sheet->setCellValue("E{$row}", $resultOfStudent->ip_address);
             $sheet->setCellValue("C{$row}", (double) $resultOfStudent->score);
         } else {
             $sheet->setCellValue("D{$row}", "Chưa làm bài");
             $sheet->setCellValue("C{$row}", "");
         }
         if (in_array($student->indentity_number, $listIndentities)) {
             $sheet->setCellValue("D{$row}", "Trùng mã số học sinh");
         }
         $listIndentities[] = $student->indentity_number;
     }
     unset($sheet);
     header('Content-type: application/vnd.ms-excel');
     header("Content-Disposition: attachment; filename=\"{$title_class}\"");
     $writer = new PHPExcel_Writer_Excel5($this->CI->phpexcel);
     $writer->save('php://output');
 }
开发者ID:nhatlang19,项目名称:elearningONL,代码行数:55,代码来源:Excel.php


示例13: silk_autoload

/**
 * The one and only autoload function for the system.  This basically allows us
 * to remove a lot of the require_once BS and keep the file loading to as much
 * of a minimum as possible.
 */
function silk_autoload($class_name)
{
    $files = scan_classes();
    if (array_key_exists('class.' . underscore($class_name) . '.php', $files)) {
        require $files['class.' . underscore($class_name) . '.php'];
    } else {
        if (array_key_exists('class.' . strtolower($class_name) . '.php', $files)) {
            require $files['class.' . strtolower($class_name) . '.php'];
        }
    }
}
开发者ID:JackSpratt,项目名称:silk,代码行数:16,代码来源:silk.api.php


示例14: getModelName

 function getModelName()
 {
     if ($this->modelName === null) {
         $className = get_class($this);
         $tmp = explode('_', underscore($className));
         $prefix = pascal(implode('_', array_slice($tmp, 0, count($tmp) - 1)));
         //echo $prefix;
         $this->modelName = $prefix . 'Model';
     }
     return $this->modelName;
 }
开发者ID:WeishengChang,项目名称:wogap,代码行数:11,代码来源:ImplicitController.php


示例15: __construct

 /**
  * Construct mongo.
  */
 function __construct($params)
 {
     parent::__construct($params);
     // Adapter represents one collection at a time.
     if ($params['name']) {
         $this->collection = underscore($params['name']);
     } else {
         throw new Exception("MongoDB adapter requires param 'name'");
     }
     // Connect!
     $this->connect();
 }
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:15,代码来源:MongoDatabase.php


示例16: __construct

 public function __construct($id = false, $type = false)
 {
     if ($type !== false) {
         $this->_type = $type;
     } elseif ($this->_type === false) {
         $this->_type = underscore(get_class($this));
     }
     if ($id !== false) {
         $this->_id = $id;
     }
     // TODO: PERHAPS $this->addCondition('id', ATTR_IS, $id);
 }
开发者ID:laiello,项目名称:php-garden,代码行数:12,代码来源:item-TODO.php


示例17: render

 protected function render($action = null)
 {
     $request = $this->request;
     $action = $action ?? $this->action;
     $view = new \app\view\Engine();
     $view->_data =& $this->_data;
     $view->includePath($this->bindViews());
     $view->currentPath(preg_replace('/\\//', '/view/', underscore($this->controller), 1));
     $view->render($action);
     $view->renderOver($this->bindOverviews());
     return $this->response->capture();
 }
开发者ID:tany,项目名称:php-note,代码行数:12,代码来源:Controller.php


示例18: cleanPath

 public function cleanPath($path)
 {
     // Accent characters should be plain text
     $accent_translation = array('á' => 'a', 'Á' => 'A', 'à' => 'a', 'À' => 'A', 'ă' => 'a', 'Ă' => 'A', 'â' => 'a', 'Â' => 'A', 'å' => 'a', 'Å' => 'A', 'ã' => 'a', 'Ã' => 'A', 'ą' => 'a', 'Ą' => 'A', 'ā' => 'a', 'Ā' => 'A', 'ä' => 'ae', 'Ä' => 'AE', 'æ' => 'ae', 'Æ' => 'AE', 'ḃ' => 'b', 'Ḃ' => 'B', 'ć' => 'c', 'Ć' => 'C', 'ĉ' => 'c', 'Ĉ' => 'C', 'č' => 'c', 'Č' => 'C', 'ċ' => 'c', 'Ċ' => 'C', 'ç' => 'c', 'Ç' => 'C', 'ď' => 'd', 'Ď' => 'D', 'ḋ' => 'd', 'Ḋ' => 'D', 'đ' => 'd', 'Đ' => 'D', 'ð' => 'dh', 'Ð' => 'Dh', 'é' => 'e', 'É' => 'E', 'è' => 'e', 'È' => 'E', 'ĕ' => 'e', 'Ĕ' => 'E', 'ê' => 'e', 'Ê' => 'E', 'ě' => 'e', 'Ě' => 'E', 'ë' => 'e', 'Ë' => 'E', 'ė' => 'e', 'Ė' => 'E', 'ę' => 'e', 'Ę' => 'E', 'ē' => 'e', 'Ē' => 'E', 'ḟ' => 'f', 'Ḟ' => 'F', 'ƒ' => 'f', 'Ƒ' => 'F', 'ğ' => 'g', 'Ğ' => 'G', 'ĝ' => 'g', 'Ĝ' => 'G', 'ġ' => 'g', 'Ġ' => 'G', 'ģ' => 'g', 'Ģ' => 'G', 'ĥ' => 'h', 'Ĥ' => 'H', 'ħ' => 'h', 'Ħ' => 'H', 'í' => 'i', 'Í' => 'I', 'ì' => 'i', 'Ì' => 'I', 'î' => 'i', 'Î' => 'I', 'ï' => 'i', 'Ï' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I', 'į' => 'i', 'Į' => 'I', 'ī' => 'i', 'Ī' => 'I', 'ĵ' => 'j', 'Ĵ' => 'J', 'ķ' => 'k', 'Ķ' => 'K', 'ĺ' => 'l', 'Ĺ' => 'L', 'ľ' => 'l', 'Ľ' => 'L', 'ļ' => 'l', 'Ļ' => 'L', 'ł' => 'l', 'Ł' => 'L', 'ṁ' => 'm', 'Ṁ' => 'M', 'ń' => 'n', 'Ń' => 'N', 'ň' => 'n', 'Ň' => 'N', 'ñ' => 'n', 'Ñ' => 'N', 'ņ' => 'n', 'Ņ' => 'N', 'ó' => 'o', 'Ó' => 'O', 'ò' => 'o', 'Ò' => 'O', 'ô' => 'o', 'Ô' => 'O', 'ő' => 'o', 'Ő' => 'O', 'õ' => 'o', 'Õ' => 'O', 'ø' => 'oe', 'Ø' => 'OE', 'ō' => 'o', 'Ō' => 'O', 'ơ' => 'o', 'Ơ' => 'O', 'ö' => 'oe', 'Ö' => 'OE', 'ṗ' => 'p', 'Ṗ' => 'P', 'ŕ' => 'r', 'Ŕ' => 'R', 'ř' => 'r', 'Ř' => 'R', 'ŗ' => 'r', 'Ŗ' => 'R', 'ś' => 's', 'Ś' => 'S', 'ŝ' => 's', 'Ŝ' => 'S', 'š' => 's', 'Š' => 'S', 'ṡ' => 's', 'Ṡ' => 'S', 'ş' => 's', 'Ş' => 'S', 'ș' => 's', 'Ș' => 'S', 'ß' => 'SS', 'ť' => 't', 'Ť' => 'T', 'ṫ' => 't', 'Ṫ' => 'T', 'ţ' => 't', 'Ţ' => 'T', 'ț' => 't', 'Ț' => 'T', 'ŧ' => 't', 'Ŧ' => 'T', 'ú' => 'u', 'Ú' => 'U', 'ù' => 'u', 'Ù' => 'U', 'ŭ' => 'u', 'Ŭ' => 'U', 'û' => 'u', 'Û' => 'U', 'ů' => 'u', 'Ů' => 'U', 'ű' => 'u', 'Ű' => 'U', 'ũ' => 'u', 'Ũ' => 'U', 'ų' => 'u', 'Ų' => 'U', 'ū' => 'u', 'Ū' => 'U', 'ư' => 'u', 'Ư' => 'U', 'ü' => 'ue', 'Ü' => 'UE', 'ẃ' => 'w', 'Ẃ' => 'W', 'ẁ' => 'w', 'Ẁ' => 'W', 'ŵ' => 'w', 'Ŵ' => 'W', 'ẅ' => 'w', 'Ẅ' => 'W', 'ý' => 'y', 'Ý' => 'Y', 'ỳ' => 'y', 'Ỳ' => 'Y', 'ŷ' => 'y', 'Ŷ' => 'Y', 'ÿ' => 'y', 'Ÿ' => 'Y', 'ź' => 'z', 'Ź' => 'Z', 'ž' => 'z', 'Ž' => 'Z', 'ż' => 'z', 'Ż' => 'Z', 'þ' => 'th', 'Þ' => 'Th', 'µ' => 'u', 'а' => 'a', 'А' => 'a', 'б' => 'b', 'Б' => 'b', 'в' => 'v', 'В' => 'v', 'г' => 'g', 'Г' => 'g', 'д' => 'd', 'Д' => 'd', 'е' => 'e', 'Е' => 'e', 'ё' => 'e', 'Ё' => 'e', 'ж' => 'zh', 'Ж' => 'zh', 'з' => 'z', 'З' => 'z', 'и' => 'i', 'И' => 'i', 'й' => 'j', 'Й' => 'j', 'к' => 'k', 'К' => 'k', 'л' => 'l', 'Л' => 'l', 'м' => 'm', 'М' => 'm', 'н' => 'n', 'Н' => 'n', 'о' => 'o', 'О' => 'o', 'п' => 'p', 'П' => 'p', 'р' => 'r', 'Р' => 'r', 'с' => 's', 'С' => 's', 'т' => 't', 'Т' => 't', 'у' => 'u', 'У' => 'u', 'ф' => 'f', 'Ф' => 'f', 'х' => 'h', 'Х' => 'h', 'ц' => 'c', 'Ц' => 'c', 'ч' => 'ch', 'Ч' => 'ch', 'ш' => 'sh', 'Ш' => 'sh', 'щ' => 'sch', 'Щ' => 'sch', 'ъ' => '', 'Ъ' => '', 'ы' => 'y', 'Ы' => 'y', 'ь' => '', 'Ь' => '', 'э' => 'e', 'Э' => 'e', 'ю' => 'ju', 'Ю' => 'ju', 'я' => 'ja', 'Я' => 'ja');
     $path = str_replace(array_keys($accent_translation), array_values($accent_translation), $path);
     // Lowercase underscore
     $path = strtolower(underscore($path));
     // Make sure it doesn't have a trailing slash
     $path = rtrim($path, '/');
     // No spaces
     $path = trim($path);
     return $path;
 }
开发者ID:vsa-partners,项目名称:typologycms,代码行数:13,代码来源:page_redirect_model.php


示例19: get_alias

 function get_alias($name)
 {
     $name = underscore($name);
     $query = $this->db->get_where('facilities', array('alias' => $name));
     if ($query->num_rows() > 0) {
         $count = $query->num_rows();
         $count++;
         $name = $name . '_' . $count;
         return $name;
     } else {
         return $name;
     }
 }
开发者ID:ageo80,项目名称:test,代码行数:13,代码来源:facility_model_core.php


示例20: transform

 public function transform($transform, $string = '')
 {
     if (empty($string)) {
         return $string;
     }
     switch ($transform) {
         case 'underscore':
             return underscore($string);
             break;
         case 'humanize':
             return humanize($string);
     }
 }
开发者ID:richtestani,项目名称:Pinups,代码行数:13,代码来源:navigation.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP undo_magic_quotes函数代码示例发布时间:2022-05-23
下一篇:
PHP uncompress函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap