本文整理汇总了PHP中strPos函数的典型用法代码示例。如果您正苦于以下问题:PHP strPos函数的具体用法?PHP strPos怎么用?PHP strPos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strPos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOurHostID
function getOurHostID()
{
$db = gs_db_slave_connect();
$rs = $db->execute('SELECT `id`, `host` FROM `hosts`');
$hosts = array();
while ($r = $rs->fetchRow()) {
$hosts[] = $r;
}
$ips = array();
foreach ($hosts as $h) {
$h['host'] = trim(normalizeIPs($h['host']));
if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $h['host'])) {
$ips[$h['host']] = $h['id'];
} else {
$tmp = getHostByNameL($h['host']);
if (is_array($tmp)) {
foreach ($tmp as $ip) {
$ips[normalizeIPs($ip)] = $h['id'];
}
}
}
}
unset($hosts);
$ifconfig = normalizeIPs(trim(@shell_exec('ifconfig 2>>/dev/null')));
foreach ($ips as $ip => $hostid) {
if (strPos($ifconfig, $ip) !== false) {
return $hostid;
}
}
return false;
}
示例2: tryRewrite
/**
* Helper for subclasses' rewrite() methods. This checks if the call can
* be rewritten at all and leaves a FIXME if it can't. If the variable's
* key is not a string starting with MODULE_, the call will not be
* considered rewritable.
*
* @return boolean
*/
protected function tryRewrite(FunctionCallNode $call, TargetInterface $target)
{
$statement = $call->getStatement();
$arguments = $call->getArguments();
if ($arguments[0] instanceof StringNode) {
$key = $arguments[0]->toValue();
if (strPos($key, $target->id() . '_') === 0) {
return TRUE;
} else {
$comment = <<<END
This looks like another module's variable. You'll need to rewrite this call
to ensure that it uses the correct configuration object.
END;
$this->buildFixMe($comment)->prependTo($statement);
return FALSE;
}
} else {
$comment = <<<END
The correct configuration object could not be determined. You'll need to
rewrite this call manually.
END;
$this->buildFixMe($comment)->prependTo($statement);
return FALSE;
}
}
示例3: get
/**
*
* @param string $type
* @return Dkplus_Model_Interface
*/
public static function get($type){
$args = func_get_args();
unset($args[0]);
$args = array_values($args);
foreach($args AS $arg){
if(
!is_int($arg)
&& !is_string($arg)
&& !is_bool($arg)
&& !is_null($arg)
){
throw new Dkplus_Model_Exception('Arguments can be only strings, ints, booleans or NULL.');
}
}
$type = (string) $type;
$blnPrefixNotNeeded = false;
foreach(self::$_prefix AS $prefix){
if(
strPos($type, $prefix) === 0
AND @class_exists($type)
){
$blnPrefixNotNeeded = true;
}
}
if(
$blnPrefixNotNeeded
){
return self::_getObject($type, $args);
}
else{
return self::_loadClass($type, $args);
}
}
示例4: siemens_push_str
function siemens_push_str($phone_ip, $postdata)
{
$prov_host = gs_get_conf('GS_PROV_HOST');
$data = "POST /server_push.html/ServerPush HTTP/1.1\r\n";
$data .= "User-Agent: Gemeinschaft\r\n";
$data .= "Host: {$phone_ip}:8085\r\n";
$data .= "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
$data .= "Connection: keep-alive\r\n";
$data .= "Content-Type: application/x-www-form-urlencoded\r\n";
$data .= "Content-Length: " . strLen($postdata) . "\r\n\r\n";
$data .= $postdata;
$socket = @fSockOpen($phone_ip, 8085, $error_no, $error_str, 4);
if (!$socket) {
gs_log(GS_LOG_NOTICE, "Siemens: Failed to open socket - IP: {$phone_ip}");
return 0;
}
stream_set_timeout($socket, 4);
$bytes_written = (int) @fWrite($socket, $data, strLen($data));
@fFlush($socket);
$response = @fGetS($socket);
@fClose($socket);
if (strPos($response, '200') === false) {
gs_log(GS_LOG_WARNING, "Siemens: Failed to push to phone {$phone_ip}");
return 0;
}
gs_log(GS_LOG_DEBUG, "Siemens: Pushed {$bytes_written} bytes to phone {$phone_ip}");
return $bytes_written;
}
示例5: uri
public function uri($uriTemplate)
{
$this->uriTemplate = $uriTemplate;
if (strPos($uriTemplate, ':') === false) {
$this->routeType = self::TYPE_STATIC;
} else {
$this->routeType = self::TYPE_PATTERN;
}
return $this;
}
示例6: verifyLCCN
function verifyLCCN()
{
## remove "-" and fill with "0" to make 8 char long
$pos = strPos($lookupVal, "-");
if ($pos > 0) {
$lccnLeft = subStr($lookupVal, 0, $pos);
$lccnRight = subStr($lookupVal, $pos + 1, 6);
$lccnRight = str_pad($lccnRight, 6, "0", STR_PAD_LEFT);
$lookupVal = $lccnLeft . $lccnRight;
}
return $lookupVal;
}
示例7: __construct
public function __construct($date, $workoutName)
{
$this->date = $date;
$this->workoutName = $workoutName;
if (strPos($workoutName, 'r') > 0) {
$this->type = self::INTERVAL;
} else {
if (strPos($workoutName, 'm')) {
$this->type = self::DISTANCE;
} else {
$this->type = self::TIME;
}
}
}
示例8: run
/**
* @return void
* @param string $url
*/
public static function run($url = null)
{
self::instance();
include SETTINGS . DS . 'routes.php';
if (null === $url) {
$url = $_SERVER['REQUEST_URI'];
if (false !== strPos($url, '?')) {
$url = subStr($url, 0, strPos($url, '?'));
}
if (self::config('web')->url && 0 === strPos($url, self::config('web')->url)) {
$url = subStr($url, strLen(self::config('web')->url));
}
if (self::config('web')->index) {
$url = preg_replace('/' . preg_quote(self::config('web')->index) . '$/', '', $url);
}
}
echo self::instance()->dispatcher->dispatch(self::instance()->routes, $url);
}
示例9: oos_validate_is_vatid
/**
* Send & request to VIES site and interprets results
*
* @access public
* @param string
* @return boolean
*/
function oos_validate_is_vatid($sVatno)
{
$sVatno = trim($sVatno);
$sVatno = strtoupper($sVatno);
$aRemove = array(' ', '-', '/', '.', ':', ',', ';', '#');
for ($i = 0, $n = count($aRemove); $i < $n; $i++) {
$sVatno = str_replace($aRemove[$i], '', $sVatno);
}
$sViesMS = substr($sVatno, 0, 2);
$sVatno = substr($sVatno, 2);
$urlVies = 'http://ec.europa.eu/taxation_customs/vies/cgi-bin/viesquer/?VAT=' . $sVatno . '&MS=' . $sViesMS . '&Lang=EN';
$DataHTML = load_data($urlVies);
if (!$DataHTML) {
return false;
}
$ViesOk = 'YES, VALID VAT NUMBER';
$ViesEr = 'NO, INVALID VAT NUMBER';
$DataHTML = '#' . strtoupper($DataHTML);
return strPos($DataHTML, $ViesOk) > 0 ? true : false;
}
示例10: getPattern
/**
* Разбирает файл или массив строк методом parse_ini_file;
*
* Проверряет существование файла, парстит его методом parse_ini и нормализует
* имена сеций([ myConfig: base] => [myConfig])
*
* Если в качестве аргумента передан масси, то он сохранятся во временный файл.
*
* TODO PHP5.3 parse_ini_string
*
* @param iFile | arrray
* @return array
*/
function getPattern($file)
{
if ($file instanceof iFile && !$file->exists()) {
throw new ConfigTaskException('File ' . $file . ' not found');
} elseif (is_array($file)) {
$tFile = new TempFile();
file_put_contents($tFile, implode('', $file));
$file = $tFile;
}
@($arr = parse_ini_file($file, true));
if ($arr === false) {
throw new Exception('Error while parsing ini-file ' . $file);
}
foreach ($arr as $sect => $c) {
if (($p = strPos($sect, Config::getInstance()->getInheritSeparator())) !== false) {
$sect2 = trim(substr($sect, 0, $p));
}
$pattern[isset($sect2) ? $sect2 : $sect] = $c;
}
return $pattern;
}
示例11: WDAddPageParams
function WDAddPageParams($page_url = "", $params = array(), $htmlSpecialChars = true)
{
$strUrl = "";
$strParams = "";
$arParams = array();
$param = "";
// Attention: $page_url already is safe.
if (is_array($params) && count($params) > 0) {
foreach ($params as $key => $val) {
if (is_array($val) && count($val) > 0 || strLen($val) > 0 && $val != "0" || intVal($val) > 0) {
if (is_array($val)) {
$param = implode(",", $val);
} else {
$param = $val;
}
if (strLen($param) > 0) {
if (strPos($page_url, $key) !== false) {
$page_url = preg_replace("/" . $key . "\\=[^\\&]*((\\&\\;)|(\\&)*)/", "", $page_url);
}
$arParams[] = $key . "=" . $param;
}
}
}
if (count($arParams) > 0) {
if (strPos($page_url, "?") === false) {
$strParams = "?";
} elseif (substr($page_url, -5, 5) != "&" && substr($page_url, -1, 1) != "&" && substr($page_url, -1, 1) != "?") {
$strParams = "&";
}
$strParams .= implode("&", $arParams);
if ($htmlSpecialChars) {
$page_url .= htmlspecialcharsbx($strParams);
} else {
$page_url .= $strParams;
}
}
}
return $page_url;
}
示例12: aastra_push_str
function aastra_push_str($phone_ip, $xml)
{
$prov_host = gs_get_conf('GS_PROV_HOST');
//FIXME - call wget or something. this function should not block
// for so long!
// see _gs_prov_phone_checkcfg_by_ip_do_aastra() in
// opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php
//$xml = utf8_decode($xml);
if (subStr($xml, 0, 5) !== '<' . '?xml') {
$xmlpi = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
} else {
$xmlpi = '';
}
$data = "POST / HTTP/1.1\r\n";
$data .= "Host: {$phone_ip}\r\n";
$data .= "Referer: {$prov_host}\r\n";
$data .= "Connection: Close\r\n";
$data .= "Content-Type: text/xml; charset=utf-8\r\n";
$data .= "Content-Length: " . (strLen('xml=') + strLen($xmlpi) + strLen($xml)) . "\r\n";
$data .= "\r\n";
$data .= 'xml=' . $xmlpi . $xml;
$socket = @fSockOpen($phone_ip, 80, $error_no, $error_str, 4);
if (!$socket) {
gs_log(GS_LOG_NOTICE, "Aastra: Failed to open socket - IP: {$phone_ip}");
return 0;
}
stream_set_timeout($socket, 4);
$bytes_written = (int) @fWrite($socket, $data, strLen($data));
@fFlush($socket);
$response = @fGetS($socket);
@fClose($socket);
if (strPos($response, '200') === false) {
gs_log(GS_LOG_WARNING, "Aastra: Failed to push XML to phone {$phone_ip}");
return 0;
}
gs_log(GS_LOG_DEBUG, "Aastra: Pushed {$bytes_written} bytes to phone {$phone_ip}");
return $bytes_written;
}
示例13: getNewPlayer
function getNewPlayer($player, $rank)
{
$race_tmp = $this->_players_array[$player]->find('td[class=race] img');
$race_src = $race_tmp[0]->src;
$race = $this->_races[substr($race_src, strpos($race_src, "race/") + 5, strPos($race_src, "-") - (strpos($race_src, "race/") + 5))];
$sex = substr($race_src, strpos($race_src, "-") + 1, 1);
$class_tmp = $this->_players_array[$player]->find('td[class=cls] img');
$class_src = $class_tmp[0]->src;
$start = strpos($class_src, "class/") + 6;
$end = strpos($class_src, ".gif");
$diff = $end - $start;
$class = $this->_classes[substr($class_src, $start, $diff)];
//echo $player.": ".$race.": ".$sex.": ".$class."<br>";
//echo $race;
$newPlayer["Name"] = $player;
$newPlayer["Race"] = $race;
$newPlayer["Class"] = $class;
$newPlayer["Sex"] = $sex;
$newPlayer["Rank"] = $rank;
$newPlayer["Spec"] = "";
$newPlayer["New"] = true;
return $newPlayer;
}
示例14: equals
/**
* This method will try to compare specific to a non-string type
* of one of the values.
* If one of the values is an object and it has method 'equals' that
* method is used.
* If both are objects or arrays and the output of print_r contains *RECURSION*
* the outputs of print_r are compared to prevent Fatal error: Nesting level too deep.
* This is a compromise as the order of keys matters and
* print_r prints 0 different from false or null.
* If both are numeric and at least one is float, they are compared with PRECISION
* In all other cases comparision is done through ==
* @param mixed $a if called by Action::check, reference (the result of parsing the string from the test)
* @param mixed $b if called by Action::check, actual (the value from the method)
* @result boolean wheather the supplied values seem to be equal
*/
public function equals($a, $b)
{
if (is_object($a) && method_exists($a, 'equals')) {
return $a->equals($b);
}
if (is_object($b) && method_exists($b, 'equals')) {
return $b->equals($a);
}
if (is_object($a) && is_object($b) || is_array($a) && is_array($b)) {
//prevent PHP Fatal error: Nesting level too deep
$aPrintR = print_r($a, true);
$bPrintR = print_r($b, true);
if (strPos($aPrintR, '*RECURSION*') !== false || strPos($bPrintR, '*RECURSION*') !== false) {
return $aPrintR == $bPrintR;
}
}
if (is_object($b) || is_array($b)) {
return $this->valueToString($a) == $b;
}
if (is_numeric($a) && is_numeric($b) && (is_float($a) || is_float($b))) {
return abs($b - $a) < $this->precision;
}
return $a == $b;
}
示例15: psetting
function psetting($sectionname, $val = '')
{
global $settings;
if (strPos($sectionname, '|')) {
list($section, $name) = explode('|', $sectionname);
if ($section !== '' && $name !== '') {
if (!array_key_exists($section, $settings) || !is_array($settings[$section])) {
$settings[$section] = array();
}
$settings[$section][$name] = $val;
}
}
}