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

PHP substru函数代码示例

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

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



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

示例1: emojifyHTML

 function emojifyHTML($text)
 {
     $elementsOpen = array();
     $elementsDepth = 0;
     while (true) {
         $elementFound = preg_match("/<\\s*?([\\/!]?\\w*)(.*?)\\s*?\\>/s", $text, $matches, PREG_OFFSET_CAPTURE, $offsetBytes);
         $element = $matches[0][0];
         $elementName = $matches[1][0];
         $elementText = $matches[2][0];
         $elementOffsetBytes = $elementFound ? $matches[0][1] : strlenb($text);
         $string = substrb($text, $offsetBytes, $elementOffsetBytes - $offsetBytes);
         if ($elementsDepth == 0) {
             $string = $this->emojifyText($string);
         }
         $output .= $string;
         if (!$elementFound) {
             break;
         }
         if (!empty($elementName) && substru($elementText, -1) != '/' && !preg_match("/^(area|br|col|hr|img|input|col|param|!)/i", $elementName)) {
             if ($elementName[0] != '/') {
                 $elementsDepth += $this->isFixedElement($elementName);
                 array_push($elementsOpen, $elementName);
             } else {
                 $elementsDepth -= $this->isFixedElement($elementsOpen[count($elementsOpen) - 1]);
                 array_pop($elementsOpen);
             }
         }
         $output .= $element;
         $offsetBytes = $elementOffsetBytes + strlenb($element);
     }
     return $output;
 }
开发者ID:wunderfeyd,项目名称:yellow-emoji,代码行数:32,代码来源:emojis.php


示例2: onParseMeta

 function onParseMeta($page)
 {
     if (substru($page->get("template"), 0, 4) == "wiki" && $this->yellow->config->get("wikiWithSidebar")) {
         if (!$page->isExisting("sidebar")) {
             $page->set("sidebar", "sidebar");
         }
     }
 }
开发者ID:nogginfuel,项目名称:yellow-extensions,代码行数:8,代码来源:wiki.php


示例3: onParseMeta

 function onParseMeta($page)
 {
     if (!$page->isError()) {
         $location = $this->yellow->config->get("blogLocation");
         if (!empty($location) && substru($page->location, 0, strlenu($location)) == $location) {
             if ($page->get("template") == $this->yellow->config->get("template")) {
                 $page->set("template", "blog");
             }
         }
     }
 }
开发者ID:richi,项目名称:yellow-extensions,代码行数:11,代码来源:blog.php


示例4: onParseContentBlock

 function onParseContentBlock($page, $name, $text, $shortcut)
 {
     $output = null;
     if ($name == "gallery" && $shortcut) {
         list($pattern, $style, $size) = $this->yellow->toolbox->getTextArgs($text);
         if (empty($style)) {
             $style = $this->yellow->config->get("galleryStyle");
         }
         if (empty($size)) {
             $size = "100%";
         }
         if (empty($pattern)) {
             $files = $page->getFiles(true);
         } else {
             $images = $this->yellow->config->get("imageDir");
             $files = $this->yellow->files->index(true, true)->match("#{$images}{$pattern}#");
         }
         if ($this->yellow->plugins->isExisting("image")) {
             if (count($files)) {
                 $page->setLastModified($files->getModified());
                 $output = "<div class=\"" . htmlspecialchars($style) . "\" data-fullscreenel=\"false\" data-shareel=\"false\"";
                 if (substru($size, -1, 1) != "%") {
                     $output .= " data-thumbsquare=\"true\"";
                 }
                 $output .= ">\n";
                 foreach ($files as $file) {
                     list($widthInput, $heightInput) = $this->yellow->toolbox->detectImageInfo($file->fileName);
                     list($src, $width, $height) = $this->yellow->plugins->get("image")->getImageInfo($file->fileName, $size, $size);
                     $output .= "<a href=\"" . $file->getLocation(true) . "\" data-size=\"{$widthInput}x{$heightInput}\">";
                     $output .= "<img src=\"" . htmlspecialchars($src) . "\" width=\"" . htmlspecialchars($width) . "\" height=\"" . htmlspecialchars($height) . "\" alt=\"" . basename($file->getLocation(true)) . "\" title=\"" . basename($file->getLocation(true)) . "\" />";
                     $output .= "</a> \n";
                 }
                 $output .= "</div>";
             } else {
                 $page->error(500, "Gallery '{$pattern}' does not exist!");
             }
         } else {
             $page->error(500, "Gallery requires 'image' plugin!");
         }
     }
     return $output;
 }
开发者ID:richi,项目名称:yellow-extensions,代码行数:42,代码来源:gallery.php


示例5: getHighlightInfo

 function getHighlightInfo($name)
 {
     $class = $this->yellow->config->get("highlightClass");
     foreach (explode(' ', $name) as $token) {
         if (empty($language) && preg_match("/^[\\w\\:]+\$/", $token)) {
             list($language, $lineNumber) = explode(':', $token);
             if (is_null($lineNumber)) {
                 $lineNumber = $this->yellow->config->get("highlightLineNumber");
             }
             continue;
         }
         if ($token[0] == '.') {
             $class = $class . " " . substru($token, 1);
         }
         if ($token[0] == '#') {
             $id = substru($token, 1);
         }
     }
     return array($language, $lineNumber, $class, $id);
 }
开发者ID:nogginfuel,项目名称:yellow-extensions,代码行数:20,代码来源:highlight.php


示例6: checkStaticFilesystem

 function checkStaticFilesystem()
 {
     return strtoupperu(substru(PHP_OS, 0, 3)) != "WIN";
 }
开发者ID:textplusdata,项目名称:yellow,代码行数:4,代码来源:commandline.php


示例7: getFileLinePrevious

 function getFileLinePrevious($fileHandle, &$filePos, &$fileTop, &$dataBuffer)
 {
     if ($filePos >= 0) {
         $line = "";
         $lineEndingSearch = false;
         $endPos = $this->getFileLineBuffer($fileHandle, $filePos, $fileTop, $dataBuffer);
         for (; $filePos >= 0; --$filePos) {
             $currentPos = $filePos - $fileTop;
             if ($dataBuffer[$currentPos] == "\n" && $lineEndingSearch) {
                 $line = substru($dataBuffer, $currentPos + 1, $endPos - $currentPos) . $line;
                 break;
             }
             if ($currentPos == 0) {
                 $line = substru($dataBuffer, $currentPos, $endPos - $currentPos + 1) . $line;
                 $endPos = $this->getFileLineBuffer($fileHandle, $filePos - 1, $fileTop, $dataBuffer);
             }
             $lineEndingSearch = true;
         }
     } else {
         $line = false;
     }
     return $line;
 }
开发者ID:Roosso,项目名称:yellow-extensions,代码行数:23,代码来源:stats.php


示例8: getCommentFileName

 function getCommentFileName($page)
 {
     if ($this->yellow->config->get("commentsDir") == "") {
         $file = $page->fileName;
         $extension = $this->yellow->config->get("contentExtension");
         if (substru($file, strlenu($file) - strlenu($extension)) == $extension) {
             $file = substru($file, 0, strlenu($file) - strlenu($extension));
         }
         $file .= $this->yellow->config->get("commentsExtension") . $extension;
         return $file;
     } else {
         return $this->yellow->config->get("commentsDir") . $page->get("pageFile");
     }
 }
开发者ID:nasendackel,项目名称:yellow-comments,代码行数:14,代码来源:comments.php


示例9: foreach

<div class="content">
<?php 
$yellow->snippet("sidebar");
?>
<div class="main">
<h1><?php 
echo $yellow->page->getHtml("title");
?>
</h1>
<ul>
<?php 
foreach ($yellow->page->getPages() as $page) {
    $sectionNew = htmlspecialchars(strtoupperu(substru($page->get("title"), 0, 1)));
    if ($section != $sectionNew) {
        $section = $sectionNew;
        echo "</ul><h2>{$section}</h2><ul>\n";
    }
    ?>
<li><a href="<?php 
    echo $page->getLocation(true);
    ?>
"><?php 
    echo $page->getHtml("title");
    ?>
</a></li>
<?php 
}
?>
</ul>
<?php 
$yellow->snippet("pagination", $yellow->page->getPages());
开发者ID:richi,项目名称:yellow-extensions,代码行数:31,代码来源:content-sitemap.php


示例10: lang

echo lang('actions');
?>
</td>
					<td colspan="2" class="item key"><?php 
echo lang('category');
?>
</td>
				</tr>
<?php 
if (is_array($topics)) {
    foreach ($topics as $row) {
        // reset
        $status = "";
        $list = "";
        // Trim subject
        $subject = substru(trim(htmlspecialchars($row['subject'], ENT_QUOTES, 'UTF-8')), 0, $config['max_length']) . "&#8230;";
        // Build topic url
        $topic_url = "{$config['url_path']}/read.php?id={$row['id']}";
        // Topic starter data
        $topic_author = user_data($row['starter_id']);
        // Topic status
        if ($row['closed']) {
            $status = 'closed, ';
        }
        if ($row['sticky']) {
            $status .= 'sticky';
        }
        $categories = category();
        // Create the delete list
        foreach ($categories as $acat) {
            if ($acat['id'] == $row['category']) {
开发者ID:amenski,项目名称:BookSharing,代码行数:31,代码来源:topics.php


示例11: detectImageInfo

 function detectImageInfo($fileName)
 {
     $width = $height = 0;
     $type = "";
     $fileHandle = @fopen($fileName, "rb");
     if ($fileHandle) {
         if (substru(strtoloweru($fileName), -3) == "png") {
             $dataSignature = fread($fileHandle, 8);
             $dataHeader = fread($fileHandle, 16);
             if (!feof($fileHandle) && $dataSignature == "‰PNG\r\n\n") {
                 $width = (ord($dataHeader[10]) << 8) + ord($dataHeader[11]);
                 $height = (ord($dataHeader[14]) << 8) + ord($dataHeader[15]);
                 $type = "png";
             }
         } else {
             if (substru(strtoloweru($fileName), -3) == "jpg") {
                 $dataBufferSizeMax = filesize($fileName);
                 $dataBufferSize = min($dataBufferSizeMax, 4096);
                 $dataBuffer = fread($fileHandle, $dataBufferSize);
                 $dataSignature = substrb($dataBuffer, 0, 4);
                 if (!feof($fileHandle) && ($dataSignature == "ÿØÿà" || $dataSignature == "ÿØÿá")) {
                     for ($pos = 2; $pos + 8 < $dataBufferSize; $pos += $length) {
                         if ($dataBuffer[$pos] != "ÿ") {
                             break;
                         }
                         if ($dataBuffer[$pos + 1] == "À" || $dataBuffer[$pos + 1] == "Â") {
                             $width = (ord($dataBuffer[$pos + 7]) << 8) + ord($dataBuffer[$pos + 8]);
                             $height = (ord($dataBuffer[$pos + 5]) << 8) + ord($dataBuffer[$pos + 6]);
                             $type = "jpg";
                             break;
                         }
                         $length = (ord($dataBuffer[$pos + 2]) << 8) + ord($dataBuffer[$pos + 3]) + 2;
                         while ($pos + $length + 8 >= $dataBufferSize) {
                             if ($dataBufferSize == $dataBufferSizeMax) {
                                 break;
                             }
                             $dataBufferDiff = min($dataBufferSizeMax, $dataBufferSize * 2) - $dataBufferSize;
                             $dataBufferSize += $dataBufferDiff;
                             $dataBuffer .= fread($fileHandle, $dataBufferDiff);
                             if (feof($fileHandle)) {
                                 $dataBufferSize = 0;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         fclose($fileHandle);
     }
     return array($width, $height, $type);
 }
开发者ID:bell0956,项目名称:bell0956,代码行数:52,代码来源:core.php


示例12: lang

					<td align="center" class="item key"><?php 
echo lang('starter_c');
?>
</td>
					<td colspan="2" class="item key"><?php 
echo lang('actions');
?>
</td>
				</tr>
<?php 
if (is_array($posts)) {
    foreach ($posts as $row) {
        // reset
        $status = "";
        // Trim subject
        $content = substru(trim(stripslashes($row['message'])), 0, 25) . "&#8230;";
        // How many replies?
        $replies = intval(get_replies($row['reply']));
        // Lets update it
        $replies = $replies + 1;
        // Woooo~ Last id for redirecting~
        $page_numbers = $replies / 20 - 1;
        $n = ceil($page_numbers);
        if ($n == -1) {
            $n = 0;
        } else {
            $n = abs($n);
        }
        // Build topic url
        $post_url = "{$config['url_path']}/read.php?id={$row['reply']}&page={$n}";
        // Topic starter data
开发者ID:amenski,项目名称:BookSharing,代码行数:31,代码来源:posts.php


示例13: getImageInfo

 function getImageInfo($fileName, $widthOutput, $heightOutput)
 {
     $fileNameShort = substru($fileName, strlenu($this->yellow->config->get("imageDir")));
     list($widthInput, $heightInput, $type) = $this->yellow->toolbox->detectImageInfo($fileName);
     $widthOutput = $this->convertValueAndUnit($widthOutput, $widthInput);
     $heightOutput = $this->convertValueAndUnit($heightOutput, $heightInput);
     if ($widthInput == $widthOutput && $heightInput == $heightOutput || $type == "svg") {
         $src = $this->yellow->config->get("serverBase") . $this->yellow->config->get("imageLocation") . $fileNameShort;
         $width = $widthOutput;
         $height = $heightOutput;
     } else {
         $fileNameThumb = ltrim(str_replace(array("/", "\\", "."), "-", dirname($fileNameShort) . "/" . pathinfo($fileName, PATHINFO_FILENAME)), "-");
         $fileNameThumb .= "-" . $widthOutput . "x" . $heightOutput;
         $fileNameThumb .= "." . pathinfo($fileName, PATHINFO_EXTENSION);
         $fileNameOutput = $this->yellow->config->get("imageThumbnailDir") . $fileNameThumb;
         if ($this->isFileNotUpdated($fileName, $fileNameOutput)) {
             $image = $this->loadImage($fileName, $type);
             $image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput);
             if (!$this->saveImage($image, $fileNameOutput, $type) || !$this->yellow->toolbox->modifyFile($fileNameOutput, $this->yellow->toolbox->getFileModified($fileName))) {
                 $this->yellow->page->error(500, "Image '{$fileNameOutput}' can't be saved!");
             }
         }
         $src = $this->yellow->config->get("serverBase") . $this->yellow->config->get("imageThumbnailLocation") . $fileNameThumb;
         list($width, $height) = $this->yellow->toolbox->detectImageInfo($fileNameOutput);
     }
     return array($src, $width, $height);
 }
开发者ID:richi,项目名称:yellow,代码行数:27,代码来源:image.php


示例14: lang

					<td colspan="2" class="item key"><?php 
echo lang('actions');
?>
</td>
					<td colspan="2" class="item key"><?php 
echo lang('category');
?>
</td>
				</tr>
<?php 
foreach ($topics as $row) {
    // reset
    $status = "";
    $list = "";
    // Trim subject
    $subject = substru(trim(stripslashes($row['subject'])), 0, $config['max_length']) . "&#8230;";
    // Build topic url
    $topic_url = "{$config['url_path']}/read.php?id={$row['id']}";
    // Topic starter data
    $topic_author = user_data($row['starter_id']);
    // Topic status
    if ($row['closed']) {
        $status = 'closed, ';
    }
    if ($row['sticky']) {
        $status .= 'sticky';
    }
    $categories = category();
    // Create the delete list
    foreach ($categories as $acat) {
        if ($acat['id'] == $row['category']) {
开发者ID:nijikokun,项目名称:NinkoBB,代码行数:31,代码来源:topics.php


示例15: analyseStaticPage

 function analyseStaticPage($text)
 {
     $serverName = $this->yellow->config->get("serverName");
     $serverBase = $this->yellow->config->get("serverBase");
     $pagination = $this->yellow->config->get("contentPagination");
     preg_match_all("/<a(.*?)href=\"([^\"]+)\"(.*?)>/i", $text, $matches);
     foreach ($matches[2] as $match) {
         if (preg_match("/^\\w+:\\/+(.*?)(\\/.*)\$/", $match, $tokens)) {
             if ($tokens[1] != $serverName) {
                 continue;
             }
             $match = $tokens[2];
         }
         if (!$this->yellow->toolbox->isLocationArgs($match)) {
             continue;
         }
         if (substru($match, 0, strlenu($serverBase)) != $serverBase) {
             continue;
         }
         $location = rawurldecode(substru($match, strlenu($serverBase)));
         if (!$this->yellow->toolbox->isLocationArgsPagination($location, $pagination)) {
             $location = rtrim($location, '/') . '/';
             if (is_null($this->locationsArgs[$location])) {
                 $this->locationsArgs[$location] = $location;
                 if (defined("DEBUG") && DEBUG >= 2) {
                     echo "YellowCommandline::analyseStaticPage detected location:{$location}\n";
                 }
             }
         } else {
             $location = rtrim($location, "0..9");
             if (is_null($this->locationsArgsPagination[$location])) {
                 $this->locationsArgsPagination[$location] = $location;
                 if (defined("DEBUG") && DEBUG >= 2) {
                     echo "YellowCommandline::analyseStaticPage detected location:{$location}\n";
                 }
             }
         }
     }
 }
开发者ID:bell0956,项目名称:bell0956,代码行数:39,代码来源:core-commandline.php


示例16: getSystemLocations

 function getSystemLocations()
 {
     $locations = array();
     $regex = "/\\.(css|ico|js|jpg|png|svg|txt|woff)/";
     $fileNames = $this->yellow->toolbox->getDirectoryEntries($this->yellow->config->get("pluginDir"), $regex, false, false);
     foreach ($fileNames as $fileName) {
         array_push($locations, $this->yellow->config->get("pluginLocation") . basename($fileName));
     }
     $fileNames = $this->yellow->toolbox->getDirectoryEntries($this->yellow->config->get("themeDir"), $regex, false, false);
     foreach ($fileNames as $fileName) {
         array_push($locations, $this->yellow->config->get("themeLocation") . basename($fileName));
     }
     $assetDirLength = strlenu($this->yellow->config->get("assetDir"));
     $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->config->get("assetDir"), $regex, false, false);
     foreach ($fileNames as $fileName) {
         array_push($locations, $this->yellow->config->get("assetLocation") . substru($fileName, $assetDirLength));
     }
     array_push($locations, "/" . $this->yellow->config->get("robotsFile"));
     return $locations;
 }
开发者ID:richi,项目名称:yellow,代码行数:20,代码来源:commandline.php


示例17: checkRequest

 function checkRequest($location)
 {
     if ($this->yellow->toolbox->getServerScheme() == $this->yellow->config->get("webinterfaceServerScheme") && $this->yellow->toolbox->getServerName() == $this->yellow->config->get("webinterfaceServerName")) {
         $locationLength = strlenu($this->yellow->config->get("webinterfaceLocation"));
         $this->active = substru($location, 0, $locationLength) == $this->yellow->config->get("webinterfaceLocation");
     }
     return $this->isActive();
 }
开发者ID:bell0956,项目名称:bell0956,代码行数:8,代码来源:core-webinterface.php


示例18: breakLongWords

function breakLongWords($str, $maxLength, $char)
{
    $wordEndChars = array(' ', "\n", "\r", "\t");
    $count = 0;
    $newStr = '';
    $tmp = substru($str, 0, 1);
    $i = 0;
    while (isset($tmp[0])) {
        $newStr .= $tmp;
        if (!in_array($tmp, $wordEndChars)) {
            $count++;
            if ($count == $maxLength) {
                $newStr .= $char;
                $count = 0;
            }
        } else {
            $count = 0;
        }
        $i++;
        $tmp = substru($str, $i, 1);
    }
    return $newStr;
}
开发者ID:Gazenwagen,项目名称:chat,代码行数:23,代码来源:index.php


示例19: onUserPermission

 function onUserPermission($location, $fileName, $users)
 {
     return substru($location, 0, strlenu($users->getHome())) == $users->getHome();
 }
开发者ID:nogginfuel,项目名称:yellow-extensions,代码行数:4,代码来源:userpermission.php


示例20: isContentFile

 function isContentFile($fileName)
 {
     $contentDirLength = strlenu($this->yellow->config->get("contentDir"));
     return substru($fileName, 0, $contentDirLength) == $this->yellow->config->get("contentDir");
 }
开发者ID:richi,项目名称:yellow,代码行数:5,代码来源:update.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP subtitle函数代码示例发布时间:2022-05-23
下一篇:
PHP substrs函数代码示例发布时间: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