本文整理汇总了PHP中PMF_String::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_String::strpos方法的具体用法?PHP PMF_String::strpos怎么用?PHP PMF_String::strpos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_String
的用法示例。
在下文中一共展示了PMF_String::strpos方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wrapLines
/**
* Wraps the lines contained into the given message.
*
* @param string $message Message.
* @param integer $width Column width. Defaults to 72.
* @param boolean $cut Cutting a word is allowed. Defaults to false.
*
* @return string The given message, wrapped as requested.
*/
public function wrapLines($message, $width = 72, $cut = false)
{
$message = $this->fixEOL($message);
if (PMF_String::strpos(strtolower($this->charset), 'utf') !== false) {
// PHP wordwrap() is not safe with multibyte UTF chars
return $message;
} else {
$lines = explode($this->eol, $message);
$wrapped = '';
foreach ($lines as $value) {
$wrapped .= empty($wrapped) ? '' : $this->eol;
$wrapped .= wordwrap($value, $width, $this->eol, $cut);
}
return $wrapped;
}
}
示例2: makeAbsoluteURL
/**
* This function converts relative uri into absolute uri using specific reference point.
* For example,
* $relativeuri = "test/foo.html"
* $referenceuri = "http://example.com:8000/sample/index.php"
* will generate "http://example.com:8000/sample/test/foo.html"
*
* @param string $relativeuri
* @param string $message
* @return string $result
* @access private
* @author Minoru TODA <todam@netjapan.co.jp>
* @since 2005-08-01
*/
function makeAbsoluteURL($relativeuri = "", $referenceuri = "")
{
// If relativeuri is protocol we don't want to handle, don't process it.
foreach ($this->invalid_protocols as $_protocol => $_message) {
if (PMF_String::strpos($relativeuri, $_protocol) === 0) {
return $relativeuri;
}
}
// If relativeuri is absolute URI, don't process it.
foreach (array("http://", "https://") as $_protocol) {
if (PMF_String::strpos($relativeuri, $_protocol) === 0) {
return $relativeuri;
}
}
// Split reference uri into parts.
$pathparts = parse_url($referenceuri);
// If port is specified in reference uri, prefix with ":"
if (isset($pathparts['port']) && $pathparts['port'] != "") {
$pathparts['port'] = ":" . $pathparts['port'];
} else {
$pathparts['port'] = "";
}
// If path is not specified in reference uri, set as blank
if (isset($pathparts['path'])) {
$pathparts['path'] = str_replace("\\", "/", $pathparts['path']);
$pathparts['path'] = preg_replace("/^.*(\\/)\$/i", "", $pathparts['path']);
} else {
$pathparts['path'] = "";
}
// Recombine urls
if (PMF_String::substr($relativeuri, 0, 1) == "/") {
return $pathparts['scheme'] . "://" . $pathparts['host'] . $pathparts['port'] . $relativeuri;
} else {
return $pathparts['scheme'] . "://" . $pathparts['host'] . $pathparts['port'] . $pathparts['path'] . "/" . $relativeuri;
}
}
示例3: strpos
/**
* Get position of the first occurence of a string
*
* @param string $haystack Haystack
* @param string $needle Needle
* @param string $offset Offset
*
* @return int
*/
public static function strpos($haystack, $needle, $offset = 0)
{
return self::$instance->strpos($haystack, $needle, $offset);
}
示例4: checkBannedWord
/**
* This function checks the content against a dab word list
* if the banned word spam protection has been activated from the general PMF configuration.
*
* @param string $content
* @return bool
* @access public
* @author Katherine A. Bouton
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Peter Beauvain <pbeauvain@web.de>
*/
function checkBannedWord($content)
{
// Sanity checks
$content = trim($content);
if ('' == $content && !PMF_Configuration::getInstance()->get('spam.checkBannedWords')) {
return true;
}
$bannedWords = getBannedWords();
// We just search a match of, at least, one banned word into $content
$content = PMF_String::strtolower($content);
if (is_array($bannedWords)) {
foreach ($bannedWords as $bannedWord) {
if (PMF_String::strpos($content, PMF_String::strtolower($bannedWord)) !== false) {
return false;
}
}
}
return true;
}
示例5: isKeyASecondPluralForm
/**
* Check if the key is a second plural form
*
* @param string $key Key
*
* @return boolean
*/
public function isKeyASecondPluralForm($key)
{
return PMF_String::strpos($key, '[1]') !== false;
}
示例6: image_two
/**
* Bild-Auswertung und Transformation
*
* Diese Funktion selektiert die Bildquelle basierend auf <img...Tag und
* transformiert diese
*
* @param string $imageString
* @return string $imageString
* @author David Sauer <david_sauer@web.de>
* @since 2005-07-21
*/
function image_two(&$imageString)
{
$img_end = PMF_String::preg_match('/\\"(\\/(.*?))\\"/', $imageString, $matches);
$source = $matches[1];
$this->xmlContent .= '<para>' . '<mediaobject>' . '<imageobject>' . '<imagedata fileref="http://localhost' . $source . '" />' . '</imageobject>' . '</mediaobject>' . '</para>';
$imageString = ltrim(PMF_String::substr($imageString, PMF_String::strpos($imageString, '/>') + 2));
}
示例7: decode
/**
* Decode a given ACE domain name
* @param string Domain name (ACE string)
* [@param string Desired output encoding, see {@link set_parameter}]
* @return string Decoded Domain name (UTF-8 or UCS-4)
*/
public function decode($input, $one_time_encoding = false)
{
// Optionally set
if ($one_time_encoding) {
switch ($one_time_encoding) {
case 'utf8':
case 'ucs4_string':
case 'ucs4_array':
break;
default:
$this->_error('Unknown encoding ' . $one_time_encoding);
return false;
}
}
// Make sure to drop any newline characters around
$input = trim($input);
// Negotiate input and try to determine, whether it is a plain string,
// an email address or something like a complete URL
if (PMF_String::strpos($input, '@')) {
// Maybe it is an email address
// No no in strict mode
if ($this->_strict_mode) {
$this->_error('Only simple domain name parts can be handled in strict mode');
return false;
}
list($email_pref, $input) = explode('@', $input, 2);
$arr = explode('.', $input);
foreach ($arr as $k => $v) {
if (PMF_String::preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) {
$conv = $this->_decode($v);
if ($conv) {
$arr[$k] = $conv;
}
}
}
$input = join('.', $arr);
$arr = explode('.', $email_pref);
foreach ($arr as $k => $v) {
if (PMF_String::preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) {
$conv = $this->_decode($v);
if ($conv) {
$arr[$k] = $conv;
}
}
}
$email_pref = join('.', $arr);
$return = $email_pref . '@' . $input;
} elseif (PMF_String::preg_match('![:\\./]!', $input)) {
// Or a complete domain name (with or without paths / parameters)
// No no in strict mode
if ($this->_strict_mode) {
$this->_error('Only simple domain name parts can be handled in strict mode');
return false;
}
$parsed = parse_url($input);
if (isset($parsed['host'])) {
$arr = explode('.', $parsed['host']);
foreach ($arr as $k => $v) {
$conv = $this->_decode($v);
if ($conv) {
$arr[$k] = $conv;
}
}
$parsed['host'] = join('.', $arr);
$return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (PMF_String::strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) . (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@') . $parsed['host'] . (empty($parsed['port']) ? '' : ':' . $parsed['port']) . (empty($parsed['path']) ? '' : $parsed['path']) . (empty($parsed['query']) ? '' : '?' . $parsed['query']) . (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
} else {
// parse_url seems to have failed, try without it
$arr = explode('.', $input);
foreach ($arr as $k => $v) {
$conv = $this->_decode($v);
$arr[$k] = $conv ? $conv : $v;
}
$return = join('.', $arr);
}
} else {
// Otherwise we consider it being a pure domain name string
$return = $this->_decode($input);
if (!$return) {
$return = $input;
}
}
// The output is UTF-8 by default, other output formats need conversion here
// If one time encoding is given, use this, else the objects property
switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
case 'utf8':
return $return;
break;
case 'ucs4_string':
return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
break;
case 'ucs4_array':
return $this->_utf8_to_ucs4($return);
break;
default:
//.........这里部分代码省略.........