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


PHP _trim函数代码示例

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


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

示例1: remove_parsecode

/**
 * Removes hook for parsecode.
 *
 * @since 1.0.0
 * @uses $parsecode_tags
 *
 * @param string $tag parsecode tag to remove hook for.
 */
function remove_parsecode($tag)
{
    global $parsecode_tags;
    if ('' == _trim($tag)) {
        $message = _t('Invalid parsecode name: empty name given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    unset($parsecode_tags[$tag]);
}
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:18,代码来源:parsecode-function.php

示例2: trim

 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string. This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  *     $str = UTF8::trim($str);
  *
  * @author  Andreas Gohr <andi@splitbrain.org>
  * @param   string  $str        input string
  * @param   string  $charlist   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = null)
 {
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Phalcana::$di->get('fs')->findFile('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = true;
     }
     return _trim($str, $charlist);
 }
开发者ID:braf,项目名称:phalcana-core,代码行数:20,代码来源:UTF8.php

示例3: etsis_php_check_includes

/**
 * Performs a check within a php script and returns any other files
 * that might have been required or included.
 *
 * @since 6.2.0
 * @param string $file_name
 *            PHP script to check.
 */
function etsis_php_check_includes($file_name)
{
    if ('' == _trim($file_name)) {
        $message = _t('Invalid file name: empty file name given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    // NOTE that any file coming into this function has already passed the syntax check, so
    // we can assume things like proper line terminations
    $includes = [];
    // Get the directory name of the file so we can prepend it to relative paths
    $dir = dirname($file_name);
    // Split the contents of $fileName about requires and includes
    // We need to slice off the first element since that is the text up to the first include/require
    $requireSplit = array_slice(preg_split('/require|include/i', _file_get_contents($file_name)), 1);
    // For each match
    foreach ($requireSplit as $string) {
        // Substring up to the end of the first line, i.e. the line that the require is on
        $string = substr($string, 0, strpos($string, ";"));
        // If the line contains a reference to a variable, then we cannot analyse it
        // so skip this iteration
        if (strpos($string, "\$") !== false) {
            continue;
        }
        // Split the string about single and double quotes
        $quoteSplit = preg_split('/[\'"]/', $string);
        // The value of the include is the second element of the array
        // Putting this in an if statement enforces the presence of '' or "" somewhere in the include
        // includes with any kind of run-time variable in have been excluded earlier
        // this just leaves includes with constants in, which we can't do much about
        if ($include = $quoteSplit[1]) {
            // If the path is not absolute, add the dir and separator
            // Then call realpath to chop out extra separators
            if (strpos($include, ':') === FALSE) {
                $include = realpath($dir . DS . $include);
            }
            array_push($includes, $include);
        }
    }
    return $includes;
}
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:49,代码来源:core-function.php

示例4: error_code

 * @license		MIT License, see license.txt
 */
namespace cs\modules\Home;

use cs\User;
$User = User::instance();
$Events = Events::instance();
if (!$User->user()) {
    error_code(403);
    return;
}
if (!isset($_POST['category'], $_POST['timeout'], $_POST['lat'], $_POST['lng'], $_POST['visible'], $_POST['text'], $_POST['time'], $_POST['time_interval'], $_POST['img'])) {
    error_code(400);
    return;
}
if (in_array(AUTOMAIDAN_GROUP, $User->get_groups()) && !in_array($_POST['category'], [1, 3, 6, 7, 8, 17, 21, 22])) {
    // Magic numbers - id of categories, where confirmation is needed
    error_code(403);
    return;
}
$tags = [];
if ($_POST['address_details']) {
    $tags = _trim(explode(',', $_POST['address_details']));
    $last = count($tags) - 1;
    if (preg_match('/^[0-9].*/s', $tags[$last])) {
        unset($tags[$last]);
    }
}
if (!$Events->add($_POST['category'], $_POST['timeout'], $_POST['lat'], $_POST['lng'], $_POST['visible'], $_POST['text'], $_POST['time'], $_POST['time_interval'], $_POST['img'], $tags)) {
    error_code(500);
}
开发者ID:hypnomez,项目名称:opir.org,代码行数:31,代码来源:index.post.php

示例5: trim

 public static function trim($str, $charlist = NULL)
 {
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require JsonApiApplication::find_file("utf8", __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _trim($str, $charlist);
 }
开发者ID:benshez,项目名称:DreamWeddingCeremonies,代码行数:9,代码来源:UTF8.php

示例6: redirect

      */
     if (isset($_COOKIE['SCREENLOCK'])) {
         redirect(get_base_url() . 'lock' . '/');
     }
 });
 $app->match('GET|POST', '/school/(\\d+)/', function ($id) use($app, $css, $js, $flashNow) {
     if ($app->req->isPost()) {
         $school = $app->db->school();
         foreach ($_POST as $k => $v) {
             $school->{$k} = $v;
         }
         $school->where('schoolID = ?', $id);
         if ($school->update()) {
             etsis_cache_flush_namespace('sch');
             $app->flash('success_message', $flashNow->notice(200));
             etsis_logger_activity_log_write('Update Record', 'School', _filter_input_string(INPUT_POST, 'schoolName') . ' (' . _trim(_filter_input_string(INPUT_POST, 'schoolCode')) . ')', get_persondata('uname'));
         } else {
             $app->flash('error_message', $flashNow->notice(409));
         }
         redirect($app->req->server['HTTP_REFERER']);
     }
     $school = $app->db->school()->where('schoolID = ?', $id);
     $q = etsis_cache_get($id, 'sch');
     if (empty($q)) {
         $q = $school->find(function ($data) {
             $array = [];
             foreach ($data as $d) {
                 $array[] = $d;
             }
             return $array;
         });
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:31,代码来源:form.router.php

示例7: trim

 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string
  *
  * This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  * Example:
  * ~~~
  * $str = UTF8::trim($str);
  * ~~~
  *
  * @author  Andreas Gohr <andi@splitbrain.org>
  *
  * @param   string  $str       Input string
  * @param   string  $charlist  String of characters to remove [Optional]
  *
  * @return  string
  *
  * @uses    Kohana::find_file
  */
 public static function trim($str, $charlist = NULL)
 {
     UTF8::_load(__FUNCTION__);
     return _trim($str, $charlist);
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:25,代码来源:utf8.php

示例8: unset

         case '!=':
         case '>':
         case '<':
         case '>=':
         case '<=':
         case 'LIKE':
         case 'NOT LIKE':
         case 'REGEXP':
         case 'NOT REGEXP':
             $search_text_ = $users_db->s($search_text);
             $where = $where_func("`%%` {$search_mode} {$search_text_}");
             unset($search_text_);
             break;
         case 'IN':
         case 'NOT IN':
             $search_text_ = implode(", ", $users_db->s(_trim(explode(',', $search_text), "\n'")));
             $where = $where_func("`%%` {$search_mode} ({$search_text_})");
             unset($search_text_);
             break;
     }
 }
 $results_count = $users_db->qfs(["SELECT COUNT(`id`)\n\t\tFROM `[prefix]users`\n\t\tWHERE\n\t\t\t(\n\t\t\t\t{$where}\n\t\t\t) AND\n\t\t\t`status` != '%s'", User::STATUS_NOT_ACTIVATED]);
 if ($results_count) {
     $from = $start * $limit;
     $users_ids = $users_db->qfas(["SELECT `id`\n\t\t\tFROM `[prefix]users`\n\t\t\tWHERE\n\t\t\t\t(\n\t\t\t\t\t{$where}\n\t\t\t\t) AND\n\t\t\t\t`status` != '%s'\n\t\t\tORDER BY `id`\n\t\t\tLIMIT {$from}, {$limit}", User::STATUS_NOT_ACTIVATED]);
     unset($from);
 }
 $users_list = [];
 if (isset($users_ids) && is_array($users_ids)) {
     foreach ($users_ids as $id) {
         $is_guest = $id == User::GUEST_ID;
开发者ID:hypnomez,项目名称:opir.org,代码行数:31,代码来源:users.php

示例9: foreach

         $post = $_POST['inst'];
         $inst = $app->db->institution()->whereLike('instName', "%{$post}%")->_or_()->whereLike('fice_ceeb', "%{$post}%");
         $q = $inst->find(function ($data) {
             $array = [];
             foreach ($data as $d) {
                 $array[] = $d;
             }
             return $array;
         });
     }
     $app->view->display('application/inst', ['title' => 'Institution Search', 'cssArray' => $css, 'jsArray' => $js, 'search' => $q]);
 });
 $app->match('GET|POST', '/inst/add/', function () use($app, $css, $js, $flashNow) {
     if ($app->req->isPost()) {
         $inst = $app->db->institution();
         $inst->fice_ceeb = _trim((int) $_POST['fice_ceeb']);
         $inst->instType = $_POST['instType'];
         $inst->instName = $_POST['instName'];
         $inst->city = $_POST['city'];
         $inst->state = $_POST['state'];
         $inst->country = $_POST['country'];
         if ($inst->save()) {
             $ID = $inst->lastInsertId();
             $app->flash('success_message', $flashNow->notice(200));
             etsis_logger_activity_log_write('New Record', 'Institution', $_POST['instName'], get_persondata('uname'));
             redirect(get_base_url() . 'appl/inst' . '/' . $ID . '/');
         } else {
             $app->flash('error_message', $flashNow->notice(409));
             redirect($app->req->server['HTTP_REFERER']);
         }
     }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:31,代码来源:appl.router.php

示例10: search

 /**
  * Precincts search
  *
  * @param string       $text
  * @param bool|float[] $coordinates
  * @param int          $limit
  *
  * @return array|bool
  */
 function search($text, $coordinates = false, $limit = 20)
 {
     $order = 'ORDER BY `district` = 0 DESC, `id` ASC';
     if ($coordinates && isset($coordinates[0], $coordinates[1])) {
         $coordinates = _float($coordinates);
         $order = "ORDER BY `district` = 0 DESC, SQRT(POW(`lat` - {$coordinates['0']}, 2) + POW(`lng` - {$coordinates['0']}, 2)) ASC";
     }
     $where = [];
     $params = [];
     if (is_numeric($text)) {
         /**
          * Search for precinct number
          */
         if (strlen($text) > 3 || (int) $text > 225) {
             $where[] = "`number` LIKE '%s%%'";
             $params[] = $text;
         } else {
             $where[] = "(`district` = '%s' OR (`district` = '0' AND `number` = '%s'))";
             $params[] = $text;
             $params[] = $text;
         }
     } else {
         $where[] = "(\n\t\t\t\tMATCH (`address_uk`) AGAINST ('%s' IN BOOLEAN MODE) > 0 OR\n\t\t\t\tMATCH (`address_en`) AGAINST ('%s' IN BOOLEAN MODE) > 0 OR\n\t\t\t\tMATCH (`address_ru`) AGAINST ('%s' IN BOOLEAN MODE) > 0\n\t\t\t)";
         $s = '+' . implode(_trim(explode(' ', trim($text))), '* +') . '*';
         $params[] = $s;
         $params[] = $s;
         $params[] = $s;
     }
     if ($where) {
         $where = 'WHERE ' . implode(' AND ', $where);
     } else {
         $where = '';
     }
     return $this->db()->qfas(["SELECT `id`\n\t\t\tFROM `{$this->table}`\n\t\t\t{$where}\n\t\t\t{$order}\n\t\t\tLIMIT {$limit}", $params]);
 }
开发者ID:hypnomez,项目名称:opir.org,代码行数:44,代码来源:Precincts.php

示例11: function

 * Before route check.
 */
$app->before('GET|POST', '/plugins.*', function () {
    if (!hasPermission('access_plugin_screen')) {
        redirect(get_base_url() . 'dashboard' . '/');
    }
});
$css = ['css/admin/module.admin.page.form_elements.min.css', 'css/admin/module.admin.page.tables.min.css'];
$js = ['components/modules/admin/forms/elements/bootstrap-select/assets/lib/js/bootstrap-select.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-select/assets/custom/js/bootstrap-select.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/select2/assets/lib/js/select2.js?v=v2.1.0', 'components/modules/admin/forms/elements/select2/assets/custom/js/select2.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-datepicker/assets/lib/js/bootstrap-datepicker.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-datepicker/assets/custom/js/bootstrap-datepicker.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-timepicker/assets/lib/js/bootstrap-timepicker.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-timepicker/assets/custom/js/bootstrap-timepicker.init.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/lib/js/jquery.dataTables.min.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/lib/extras/TableTools/media/js/TableTools.min.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/custom/js/DT_bootstrap.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/custom/js/datatables.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/jCombo/jquery.jCombo.min.js', 'components/modules/admin/forms/elements/jasny-fileupload/assets/js/bootstrap-fileupload.js?v=v2.1.0'];
$app->group('/plugins', function () use($app, $css, $js) {
    $app->get('/', function () use($app, $css, $js) {
        $app->view->display('plugins/index', ['title' => _t('Plugins'), 'cssArray' => $css, 'jsArray' => $js]);
    });
    $app->get('/activate/', function () use($app) {
        ob_start();
        $plugin_name = _trim(_filter_input_string(INPUT_GET, 'id'));
        /**
         * This function will validate a plugin and make sure
         * there are no errors before activating it.
         *
         * @since 6.2.0
         */
        etsis_validate_plugin($plugin_name);
        if (ob_get_length() > 0) {
            $output = ob_get_clean();
            $error = new \app\src\etError('unexpected_output', _t('The plugin generated unexpected output.'), $output);
            $app->flash('error_message', $error);
        }
        ob_end_clean();
        redirect($app->req->server['HTTP_REFERER']);
    });
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:31,代码来源:plugins.router.php

示例12: send_to

 /**
  * Sending of email
  *
  * @param array|string|string[]			$email			if emails without names - string (may be several emails separated by comma) or
  * 														1-dimensional array(<i>email</i>)<br>
  * 														else - 2-dimensional array(<i>email</i>, <i>name</i>) must be given
  * @param string						$subject		Mail subject
  * @param string						$body			html body
  * @param string|null					$body_text		plain text body
  * @param array|null|string				$attachments	1- or 2-dimensional array of array(<i>path</i>, <i>name</i>) or simply string
  * 														with path to the file in file system
  * @param array|null|string|string[]	$reply_to		Similar to <b>$email</b>
  * @param bool|string					$signature		<b>true</b> - add system signature<br>
  * 														<b>false</b> - without signature<br>
  * 														<b>string</b> - custom signature
  * @return bool
  */
 function send_to($email, $subject, $body, $body_text = null, $attachments = null, $reply_to = null, $signature = true)
 {
     if (empty($email) || empty($subject) || empty($body)) {
         return false;
     }
     if (is_array($email)) {
         if (count($email) == 2) {
             $this->AddAddress($email[0], $email[1]);
         } else {
             foreach ($email as $m) {
                 if (is_array($m)) {
                     $this->AddAddress($m[0], $m[1]);
                 } else {
                     $this->AddAddress($m);
                 }
             }
         }
     } else {
         $email = _trim(explode(',', $email));
         foreach ($email as $e) {
             $this->AddAddress($e);
         }
         unset($e, $email);
     }
     $this->Subject = $subject;
     if ($signature === true) {
         if ($signature = get_core_ml_text('mail_signature')) {
             $signature = "{$this->LE}-- {$this->LE}.{$signature}";
         }
     } elseif ($signature) {
         $signature = "{$this->LE}-- {$this->LE}" . xap($signature, true);
     } else {
         $signature = '';
     }
     $this->Body = $this->body_normalization($body, $signature);
     if ($body_text) {
         $this->AltBody = $body_text . strip_tags($signature);
     }
     if (is_array($attachments)) {
         if (count($attachments) == 2) {
             $this->AddStringAttachment($attachments[0], $attachments[1]);
         } else {
             foreach ($attachments as $a) {
                 if (is_array($a)) {
                     $this->AddStringAttachment($a[0], $a[1]);
                 } else {
                     $this->AddStringAttachment($a, pathinfo($a, PATHINFO_FILENAME));
                 }
             }
         }
     } elseif (is_string($attachments)) {
         $this->AddStringAttachment($attachments, pathinfo($attachments, PATHINFO_FILENAME));
     }
     if (is_array($reply_to)) {
         if (count($reply_to) == 2) {
             $this->AddReplyTo($reply_to[0], $reply_to[1]);
         } else {
             foreach ($reply_to as $r) {
                 if (is_array($r)) {
                     $this->AddReplyTo($r[0], $r[1]);
                 } else {
                     $this->AddReplyTo($r);
                 }
             }
         }
     } elseif (is_string($reply_to)) {
         $this->AddReplyTo($reply_to);
     }
     $result = $this->Send();
     $this->ClearAddresses();
     $this->ClearAttachments();
     $this->ClearReplyTos();
     return $result;
 }
开发者ID:hypnomez,项目名称:opir.org,代码行数:91,代码来源:Mail.php

示例13: do_action

/**
 * Wrapper function for Hooks::do_action() and
 * executes functions hooked on a specific action hook.
 *
 * @since 6.0.03
 * @deprecated since 6.2.0
 * @param string $hook
 *            The name of the action which should be executed.
 * @param mixed $arg
 *            Additional arguments passed to functions hooked to the action.
 * @return mixed|null
 */
function do_action($hook, $arg = '')
{
    if ('' == _trim($hook)) {
        $message = _t('Invalid do_action hook: empty hook name given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    if (!is_string($hook)) {
        $message = _t('Invalid do_action hook: hook name must be a string.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    $app = \Liten\Liten::getInstance();
    return $app->hook->do_action($hook, $arg);
}
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:27,代码来源:dependency.php

示例14: _trim

     $sacp = $app->db->stu_program();
     $sacp->stuID = $id;
     $sacp->acadProgCode = _trim($_POST['acadProgCode']);
     $sacp->currStatus = $_POST['currStatus'];
     $sacp->statusDate = $app->db->NOW();
     $sacp->startDate = $_POST['startDate'];
     $sacp->endDate = $_POST['endDate'];
     $sacp->approvedBy = get_persondata('personID');
     $sacp->antGradDate = $_POST['antGradDate'];
     $sacp->advisorID = $_POST['advisorID'];
     $sacp->catYearCode = $_POST['catYearCode'];
     if ($sacp->save()) {
         if (count($sql[0]['id']) <= 0) {
             $al = $app->db->stu_acad_level();
             $al->stuID = $id;
             $al->acadProgCode = _trim($_POST['acadProgCode']);
             $al->acadLevelCode = $decode[0]['acadLevelCode'];
             $al->addDate = $app->db->NOW();
             $al->save();
         }
         $app->flash('success_message', $flashNow->notice(200));
         etsis_logger_activity_log_write('New Record', 'Student Academic Program', get_name($id), get_persondata('uname'));
         redirect(get_base_url() . 'stu' . '/' . $id . '/' . bm());
     } else {
         $app->flash('error_message', $flashNow->notice(409));
         $app->req->server['HTTP_REFERER'];
     }
     etsis_cache_delete($id, 'stu');
 }
 $stu = $app->db->student()->where('stuID = ?', $id);
 $q = $stu->find(function ($data) {
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:31,代码来源:student.router.php

示例15: _trim

      * @param array $sect Course section object.
      */
     $app->hook->do_action('save_course_sec_db_table', $sect);
     if ($sect->save()) {
         $ID = $sect->lastInsertId();
         $section = ["sectionNumber" => _trim($_POST['sectionNumber']), "courseSecCode" => _trim($sc), "courseID" => $_POST['courseID'], "locationCode" => _trim($_POST['locationCode']), "termCode" => _trim($_POST['termCode']), "courseCode" => _trim($_POST['courseCode']), "secShortTitle" => $_POST['secShortTitle'], "startDate" => $_POST['startDate'], "endDate" => $_POST['endDate'], "deptCode" => _trim($_POST['deptCode']), "minCredit" => $_POST['minCredit'], "ceu" => $_POST['ceu'], "courseSection" => _trim($courseSection), "courseLevelCode" => _trim($_POST['courseLevelCode']), "acadLevelCode" => _trim($_POST['acadLevelCode']), "currStatus" => $_POST['currStatus'], "statusDate" => $_POST['statusDate'], "comment" => $_POST['comment'], "approvedDate" => $_POST['approvedDate'], "approvedBy" => $_POST['approvedBy'], "secLongTitle" => $crse->courseLongTitle, "section" => _trim($courseSection), "description" => $crse->courseDesc];
         /**
          * Fires after a course section has been created.
          * 
          * @since 6.1.07
          * @param array $section Course section data array.
          */
         $app->hook->do_action('post_save_course_sec', $section);
         etsis_cache_flush_namespace('sect');
         $app->flash('success_message', $flashNow->notice(200));
         etsis_logger_activity_log_write('New Record', 'Course Section', _trim($courseSection), get_persondata('uname'));
         redirect(get_base_url() . 'sect' . '/' . $ID . '/');
     } else {
         $app->flash('error_message', $flashNow->notice(409));
         redirect($app->req->server['HTTP_REFERER']);
     }
 }
 /**
  * If the database table doesn't exist, then it
  * is false and a 404 should be sent.
  */
 if ($crse == false) {
     $app->view->display('error/404', ['title' => '404 Error']);
 } elseif (empty($crse) == true) {
     $app->view->display('error/404', ['title' => '404 Error']);
 } elseif (count($crse->courseID) <= 0) {
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:31,代码来源:section.router.php


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