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


PHP Trim函数代码示例

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


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

示例1: GetSiteByHost

	/**
	 * <p>Возвращает идентификатор сайта, определяя его по текущему хосту. Если идентификатор сайта неверный, то вернет - "false".</p>
	 *
	 *
	 *
	 *
	 * @return mixed 
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * &lt;?
	 * require($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include/mainpage.php");
	 * 
	 * if($page = CMainPage::GetIncludeSitePage(<b>CMainPage::GetSiteByHost</b>()))
	 *     require_once($page);
	 * 
	 * require($_SERVER['DOCUMENT_ROOT']."/bitrix/header.php");?&gt;
	 * &lt;?require($_SERVER['DOCUMENT_ROOT']."/bitrix/footer.php");?&gt;
	 * </pre>
	 *
	 *
	 *
	 * <h4>See Also</h4> 
	 * <ul> <li> <a href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;LESSON_ID=2833" >Список
	 * терминов</a> </li> <li> <a
	 * href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;CHAPTER_ID=03987"
	 * >Конфигурирование многосайтовости</a> </li> </ul><a name="examples"></a>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/main/reference/cmainpage/getsitebyhost.php
	 * @author Bitrix
	 */
	public static function GetSiteByHost()
	{
		$cur_host = $_SERVER["HTTP_HOST"];
		$arURL = parse_url("http://".$cur_host);
		if($arURL["scheme"]=="" && strlen($arURL["host"])>0)
			$CURR_DOMAIN = $arURL["host"];
		else
			$CURR_DOMAIN = $cur_host;

		if(strpos($CURR_DOMAIN, ':')>0)
			$CURR_DOMAIN = substr($CURR_DOMAIN, 0, strpos($CURR_DOMAIN, ':'));
		$CURR_DOMAIN = Trim($CURR_DOMAIN, "\t\r\n\0 .");

		global $DB;
		$strSql =
			"SELECT L.LID as SITE_ID ".
			"FROM b_lang L, b_lang_domain LD ".
			"WHERE L.ACTIVE='Y' ".
			"	AND L.LID=LD.LID ".
			"	AND '".$DB->ForSql($CURR_DOMAIN, 255)."' LIKE ".$DB->Concat("'%'", "LD.DOMAIN")." ".
			"ORDER BY ".$DB->Length("LD.DOMAIN")." DESC, L.SORT";

		$res = $DB->Query($strSql);
		if($ar_res = $res->Fetch())
			return $ar_res["SITE_ID"];

		$sl = CSite::GetDefList();
		while ($slang = $sl->Fetch())
			if($slang["DEF"]=="Y")
				return $slang["SITE_ID"];

		return false;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:67,代码来源:mainpage.php

示例2: GetReportsList

function GetReportsList($strPath2Export)
{
    $arReports = array();
    CheckDirPath($_SERVER["DOCUMENT_ROOT"] . $strPath2Export);
    if ($handle = opendir($_SERVER["DOCUMENT_ROOT"] . $strPath2Export)) {
        while (($file = readdir($handle)) !== false) {
            if ($file == "." || $file == "..") {
                continue;
            }
            if (is_file($_SERVER["DOCUMENT_ROOT"] . $strPath2Export . $file) && substr($file, strlen($file) - 8) == "_run.php") {
                $export_name = substr($file, 0, strlen($file) - 8);
                $rep_title = $export_name;
                $file_handle = fopen($_SERVER["DOCUMENT_ROOT"] . $strPath2Export . $file, "rb");
                $file_contents = fread($file_handle, 1500);
                fclose($file_handle);
                $arMatches = array();
                if (preg_match("#<title[\\s]*>([^<]*)</title[\\s]*>#i", $file_contents, $arMatches)) {
                    $arMatches[1] = Trim($arMatches[1]);
                    if (strlen($arMatches[1]) > 0) {
                        $rep_title = $arMatches[1];
                    }
                }
                $arReports[$export_name] = array("PATH" => $strPath2Export, "FILE_RUN" => $strPath2Export . $file, "TITLE" => $rep_title);
                if (file_exists($_SERVER["DOCUMENT_ROOT"] . $strPath2Export . $export_name . "_setup.php")) {
                    $arReports[$export_name]["FILE_SETUP"] = $strPath2Export . $export_name . "_setup.php";
                }
            }
        }
    }
    closedir($handle);
    return $arReports;
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:32,代码来源:export_setup.php

示例3: CorrectNumber

 public static function CorrectNumber(&$uNumber)
 {
     $uNumber = Trim($uNumber);
     $ret =& $uNumber;
     if (substr($uNumber, 0, 3) == '%2B') {
         $ret = substr($uNumber, 3);
         $uNumber = $ret;
     }
     if (substr($uNumber, 0, 3) == '%2b') {
         $ret = substr($uNumber, 3);
         $uNumber = $ret;
     }
     if (substr($uNumber, 0, 4) == '0098') {
         $ret = substr($uNumber, 4);
         $uNumber = $ret;
     }
     if (substr($uNumber, 0, 3) == '098') {
         $ret = substr($uNumber, 3);
         $uNumber = $ret;
     }
     if (substr($uNumber, 0, 3) == '+98') {
         $ret = substr($uNumber, 3);
         $uNumber = $ret;
     }
     if (substr($uNumber, 0, 2) == '98') {
         $ret = substr($uNumber, 2);
         $uNumber = $ret;
     }
     if (substr($uNumber, 0, 1) == '0') {
         $ret = substr($uNumber, 1);
         $uNumber = $ret;
     }
     return '+98' . $ret;
 }
开发者ID:parsidev,项目名称:azinsms,代码行数:34,代码来源:Azinsms.php

示例4: AuditRecords_Main

function AuditRecords_Main($article)
{
    global $zbp;
    if (isset($_POST['AuditRecords_op'])) {
        $ar = new AuditRecords();
        $ar->LogID = $article->ID;
        $ar->AuthorID = $zbp->user->ID;
        $ar->Logs = Trim(GetVars('AuditRecords_logs', 'POST'));
        $ar->Opeate = GetVars('AuditRecords_op', 'POST');
        if (!$ar->Logs) {
            if ($ar->Opeate == -1) {
                $ar->Logs = "我有更新了,麻烦请审核一下。";
            }
            if ($ar->Opeate == 0) {
                $ar->Logs = "不想写审核意见,还是不通过。";
            }
            if ($ar->Opeate == 1) {
                $ar->Logs = "通过了通过了,真的没有意见。";
            }
        }
        $ar->PostTime = time();
        $ar->Save();
        foreach ($GLOBALS['Filter_Plugin_AuditRecords_Submit'] as $fpname => &$fpsignal) {
            $fpname($article, $ar->Opeate, $ar->Logs);
        }
    }
}
开发者ID:zblogcn,项目名称:zblogphp,代码行数:27,代码来源:include.php

示例5: Render

 function Render($AID)
 {
     $vData = $this->LoadData($AID);
     //        $this->DocTitle = Trim('№ '.$vData['case_id'].' / '.$vData['case']['last_name'].' '.$vData['case']['first_name'][0].'.'.$vData['case']['patr_name'][0].'.');
     //        $this->DocTitle = Trim($vData['case_id'].' / '.FormatShortName($vData['case']['last_name'],$vData['case']['first_name'],$vData['case']['patr_name']));
     $this->DocTitle = Trim($vData['case_id'] . ' / ' . FormatShortNameEx($vData['case']));
     $this->SetMargins(10, 10, 5);
     $this->SetAutoPageBreak(true, 30);
     $this->FirstPage($vData);
 }
开发者ID:uisluu,项目名称:emst,代码行数:10,代码来源:rg_dir_pdf.php

示例6: GetRegionLangByID

 /**
  * The function returns the languages parameters for region
  * @param int $ID region code
  * @param string $strLang the current language
  * @return array $res region parameters
  */
 function GetRegionLangByID($ID, $strLang = LANGUAGE_ID)
 {
     global $DB;
     $ID = IntVal($ID);
     $strLang = Trim($strLang);
     $strSql = "SELECT * " . "FROM b_sale_location_region_lang " . "WHERE REGION_ID = " . $ID . " " . " AND LID = '" . $DB->ForSql($strLang, 2) . "' ";
     $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($res = $db_res->Fetch()) {
         return $res;
     }
     return False;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:18,代码来源:location.php

示例7: ValidarUserSession

function ValidarUserSession()
{
    if (!isset($_SESSION["isAbogado"]) and !isset($_SESSION["idUsuario"])) {
        //validarSesion(false);
        echo "<script src=\"/js/functions.js?rnd=" . RandomNumber() . "\" type=\"text/javascript\"></script>";
        echo "<script>if (!isTopLevel(window)) alert('Se sesión ha expirado.\\nPor favor logueese nuevamente para continuar.');</script>";
        echo "<span id=\"sesionInvalidData\">" . $_SERVER["REMOTE_ADDR"] . " (" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ")</span><br />";
        echo "<span id=\"sesionInvalidMsg\"> " . Trim("Ha expirado la sesión, por favor ingrese nuevamente sus datos.");
        exit;
    }
    ValidarJS();
}
开发者ID:javierlov,项目名称:FuentesWeb,代码行数:12,代码来源:FuncionesLegales.php

示例8: friendly_url

 public static function friendly_url($text)
 {
     $friendlyurl = Str_Replace(' ', '-', AddSlashes($text));
     $tbl = array("á" => "a", "ä" => "a", "č" => "c", "ď" => "d", "é" => "e", "ě" => "e", "í" => "i", "ľ" => "l", "ĺ" => "l", "ň" => "n", "ó" => "o", "ö" => "o", "ő" => "o", "ô" => "o", "ř" => "r", "ŕ" => "r", "š" => "s", "ť" => "t", "ú" => "u", "ů" => "u", "ü" => "u", "ű" => "u", "ý" => "y", "ž" => "z", "Á" => "A", "Ä" => "A", "Č" => "C", "Ď" => "D", "É" => "E", "Ě" => "E", "Í" => "I", "Ľ" => "L", "Ĺ" => "L", "Ň" => "N", "Ó" => "O", "Ö" => "O", "Ő" => "O", "Ô" => "O", "Ř" => "R", "Ŕ" => "R", "Š" => "S", "Ť" => "T", "Ú" => "U", "Ů" => "U", "Ü" => "U", "Ű" => "U", "Ý" => "Y", "Ž" => "Z", "'" => "", ",-" => "kc");
     $url = StrTr($friendlyurl, $tbl);
     $text = StrTr($url, "ÁÄČÇĎÉĚËÍŇÓÖŘŠŤÚŮÜÝŽáäčçďéěëíňóöřšťúůüýž", "AACCDEEEINOORSTUUUYZaaccdeeeinoorstuuuyz");
     // somehow I wasnt able to add following characters to previous StrTr strings:
     $text = StrTr($text, "& .,?!_+", "--------");
     //$text = Preg_Replace ("/[^[:alpha:][:digit:]]/", "-", $text);
     $text = Trim($text, "-");
     $text = Preg_Replace("/[-]+/", "-", $text);
     return strtolower($text);
 }
开发者ID:petrparolek,项目名称:web_cms,代码行数:13,代码来源:UrlExtended.php

示例9: disconnect

 public function disconnect()
 {
     if ($this->mbox) {
         $this->expungeDeletedMessages();
         $errors = imap_errors();
         if ($errors) {
             foreach ($errors as $error) {
                 #trigger_error($error);
                 Debug(SPrintF('[system/classes/ImapMailbox]: %s', Trim($error)));
             }
         }
         imap_close($this->mbox);
         $this->mbox = null;
     }
 }
开发者ID:carriercomm,项目名称:jbs,代码行数:15,代码来源:ImapMailbox.php

示例10: Request

 function Request($server, $page, $port, $params, $uri = false)
 {
     if ($uri && strlen($uri) > 0) {
         $strURI = $uri;
     } else {
         $strURI = "http://" . $server . (strlen($port) > 0 && intval($port) > 0 ? ":" . intval($port) : "") . (strlen($page) ? $page : "/") . (strlen($params) > 0 ? "?" . $params : "");
     }
     $http = new \Bitrix\Main\Web\HttpClient(array("version" => "1.0", "socketTimeout" => 30, "streamTimeout" => 30, "redirect" => true, "redirectMax" => 5));
     $strData = $http->get($strURI);
     $errors = $http->getError();
     $arRSSResult = array();
     if (!$strData && !empty($errors)) {
         $strError = "";
         foreach ($errors as $errorCode => $errMes) {
             $strError .= $errorCode . ": " . $errMes;
         }
         \CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "XDIMPORT_HTTP", "MODULE_ID" => "xdimport", "ITEM_ID" => "RSS_REQUEST", "DESCRIPTION" => $strError));
     }
     if ($strData) {
         $rss_charset = "windows-1251";
         if (preg_match("/<" . "\\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\\?" . ">/i", $strData, $matches)) {
             $rss_charset = Trim($matches[1]);
         }
         $strData = preg_replace("/<" . "\\?XML.*?\\?" . ">/i", "", $strData);
         $strData = $GLOBALS["APPLICATION"]->ConvertCharset($strData, $rss_charset, SITE_CHARSET);
     }
     if (strlen($strData) > 0) {
         require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
         $objXML = new CDataXML();
         $res = $objXML->LoadString($strData);
         if ($res !== false) {
             $ar = $objXML->GetArray();
             if (is_array($ar) && isset($ar["rss"]) && is_array($ar["rss"]) && isset($ar["rss"]["#"]) && is_array($ar["rss"]["#"]) && isset($ar["rss"]["#"]["channel"]) && is_array($ar["rss"]["#"]["channel"]) && isset($ar["rss"]["#"]["channel"][0]) && is_array($ar["rss"]["#"]["channel"][0]) && isset($ar["rss"]["#"]["channel"][0]["#"])) {
                 $arRSSResult = $ar["rss"]["#"]["channel"][0]["#"];
             } else {
                 $arRSSResult = array();
             }
             $arRSSResult["rss_charset"] = strtolower(SITE_CHARSET);
         }
     }
     if (is_array($arRSSResult) && !empty($arRSSResult)) {
         $arRSSResult = CXDILFSchemeRSS::FormatArray($arRSSResult);
         if (!empty($arRSSResult) && array_key_exists("item", $arRSSResult) && is_array($arRSSResult["item"]) && !empty($arRSSResult["item"])) {
             $arRSSResult["item"] = array_reverse($arRSSResult["item"]);
         }
     }
     return $arRSSResult;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:48,代码来源:lf_scheme_rss.php

示例11: RGBToHex

 function RGBToHex($colorR, $colorG, $colorB)
 {
     $colorR = Trim($colorR);
     $colorG = Trim($colorG);
     $colorB = Trim($colorB);
     //	Calculate every single letter-number
     $a = $this->_convertToHex(floor($colorR / 16));
     $b = $this->_convertToHex($colorR % 16);
     $c = $this->_convertToHex(floor($colorG / 16));
     $d = $this->_convertToHex($colorG % 16);
     $e = $this->_convertToHex(floor($colorB / 16));
     $f = $this->_convertToHex($colorB % 16);
     //	Build the Hexa Code
     $color = $a . $b . $c . $d . $e . $f;
     return $color;
 }
开发者ID:hukumonline,项目名称:quart80,代码行数:16,代码来源:ColorConverter.php

示例12: RequireAutoloadClass

	static function RequireAutoloadClass($className)
	{
		$className = Trim($className);
		if (StrLen($className) <= 0)
			return False;

		$className = strtolower($className);

		if (array_key_exists($className, $GLOBALS["arBitrixModuleClasses"]))
		{
			require_once($_SERVER["DOCUMENT_ROOT"].((StrLen($GLOBALS["arBitrixModuleClasses"][$className]["module"]) > 0) ? BX_ROOT."/modules/".$GLOBALS["arBitrixModuleClasses"][$className]["module"]."/" : "").$GLOBALS["arBitrixModuleClasses"][$className]["file"]);
			return True;
		}

		return False;
	}
开发者ID:nProfessor,项目名称:Mytb,代码行数:16,代码来源:module.php

示例13: CheckAccess

 function CheckAccess($userID, $itemMD5, $periodLength, $periodType)
 {
     global $DB;
     $userID = IntVal($userID);
     if ($userID <= 0) {
         return false;
     }
     $itemMD5 = Trim($itemMD5);
     if (strlen($itemMD5) <= 0) {
         return false;
     }
     $periodLength = IntVal($periodLength);
     if ($periodLength <= 0) {
         return False;
     }
     $periodType = Trim($periodType);
     $periodType = ToUpper($periodType);
     if (strlen($periodType) <= 0) {
         return False;
     }
     $checkVal = 0;
     if ($periodType == "I") {
         $checkVal = mktime(date("H"), date("i") - $periodLength, date("s"), date("m"), date("d"), date("Y"));
     } elseif ($periodType == "H") {
         $checkVal = mktime(date("H") - $periodLength, date("i"), date("s"), date("m"), date("d"), date("Y"));
     } elseif ($periodType == "D") {
         $checkVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - $periodLength, date("Y"));
     } elseif ($periodType == "W") {
         $checkVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 7 * $periodLength, date("Y"));
     } elseif ($periodType == "M") {
         $checkVal = mktime(date("H"), date("i"), date("s"), date("m") - $periodLength, date("d"), date("Y"));
     } elseif ($periodType == "Q") {
         $checkVal = mktime(date("H"), date("i"), date("s"), date("m") - 3 * $periodLength, date("d"), date("Y"));
     } elseif ($periodType == "S") {
         $checkVal = mktime(date("H"), date("i"), date("s"), date("m") - 6 * $periodLength, date("d"), date("Y"));
     } elseif ($periodType == "Y") {
         $checkVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") - $periodLength);
     }
     if ($checkVal <= 0) {
         return False;
     }
     $dbAuxiliary = CSaleAuxiliary::GetList(array(), array("USER_ID" => $userID, "ITEM_MD5" => $itemMD5, ">=DATE_INSERT" => Date($GLOBALS["DB"]->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), $checkVal)), false, false, array("*"));
     if ($arAuxiliary = $dbAuxiliary->Fetch()) {
         return $arAuxiliary;
     }
     return false;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:47,代码来源:auxiliary.php

示例14: Update

 function Update($ID, $arFields)
 {
     global $DB;
     $ID = intval($ID);
     if ($ID <= 0) {
         return false;
     }
     if (!CCatalogProductGroups::CheckFields("UPDATE", $arFields, $ID)) {
         return False;
     }
     $strUpdate = $DB->PrepareUpdate("b_catalog_product2group", $arFields);
     $strUpdate = Trim($strUpdate);
     if (StrLen($strUpdate) > 0) {
         $strSql = "UPDATE b_catalog_product2group SET " . $strUpdate . " WHERE ID = " . $ID . " ";
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $ID;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:18,代码来源:product_group.php

示例15: widget

 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $EVT_DefLabels, $EVT_CalenderSettingNames, $EVT_ServerSettingNames, $EVT_QuerySettingNames, $EVT_DefValues;
     $wg_atts = $args;
     foreach ($instance as $key => $value) {
         $wg_atts[$key] = Trim(empty($instance[$key]) ? $EVT_DefValues[$key] : $instance[$key]);
     }
     $wg_atts['title'] = apply_filters('widget_title', $wg_atts['title']);
     if ($wg_atts['script'] == '') {
         $wg_atts['script'] = 'xml.php';
     }
     $termine = postprocess_xml(evt_getevents($wg_atts, $EVT_QuerySettingNames), 'widget');
     echo $before_widget;
     if ($wg_atts['title']) {
         echo $before_title . $wg_atts['title'] . $after_title;
     }
     echo $termine;
     // Hier ist der richtige Patz um den erzeugten HTML Code auszugeben.
     echo "<p style=\"font-size: x-small;\">Powered by Evangelische Termine Plugin - &copy Thomas Arend, Rheinbach</p>";
     echo $after_widget;
 }
开发者ID:Byggvir,项目名称:evangelische_termine,代码行数:22,代码来源:widget.php


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