本文整理汇总了PHP中in_string函数的典型用法代码示例。如果您正苦于以下问题:PHP in_string函数的具体用法?PHP in_string怎么用?PHP in_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了in_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Converts an XML url or string to a PHP array format
*
* @static
* @access public
* @param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which.
* @return array Parsed XML
* @throws BadEntryError
* @throws DependencyError
* @throws HookError
* @throws XMLError
*/
public static function load($data)
{
$http = HTTP::getDefaultInstance();
if (!function_exists('simplexml_load_string')) {
throw new DependencyError("SimpleXML", "http://us.php.net/manual/en/book.simplexml.php");
}
libxml_use_internal_errors(true);
if (in_string("<?xml", $data)) {
$xmlout = $data;
} else {
$xmlout = $http->get($data);
}
Hooks::runHook('PreSimpleXMLLoad', array(&$xmlout));
$xml = simplexml_load_string($xmlout);
Hooks::runHook('PostSimpleXMLLoad', array(&$xml));
if (!$xml) {
foreach (libxml_get_errors() as $error) {
throw new XMLError($error);
}
}
$outArr = array();
$namespaces = $xml->getNamespaces(true);
$namespaces['default'] = '';
self::recurse($xml, $outArr, $namespaces);
libxml_clear_errors();
return $outArr;
}
示例2: getBlameResult
public static function getBlameResult($wiki, $article, $nofollowredir, $text)
{
try {
$site = Peachy::newWiki(null, null, null, 'http://' . $wiki . '/w/api.php');
} catch (Exception $e) {
return null;
}
$pageClass = $site->initPage($article, null, !$nofollowredir);
$title = $pageClass->get_title();
$history = $pageClass->history(null, 'older', true);
$revs = array();
foreach ($history as $id => $rev) {
if ($id + 1 == count($history)) {
if (in_string($text, $rev['*'], true)) {
$revs[] = self::parseRev($rev, $wiki, $title);
}
} else {
if (in_string($text, $rev['*'], true) && !in_string($text, $history[$id + 1]['*'], true)) {
$revs[] = self::parseRev(${$rev}, $wiki, $title);
}
}
unset($rev);
//Saves memory
}
return $revs;
}
示例3: p11n
function p11n($locale)
{
$args = func_get_args();
$locale = array_shift($args);
$num_args = count($args);
if ($num_args == 0) {
return $locale;
}
if (in_string('|', $locale)) {
$n = NULL;
$locale = explode('|', $locale);
$count = count($locale);
foreach ($locale as $i => &$l) {
if (preg_match('/^\\{(\\d+?)\\}|\\[(\\d+?),(\\d+?|Inf)\\]/', $l, $match)) {
$n = end($match);
if ($n == 'Inf') {
break;
}
} else {
if (is_null($n)) {
$l = '[0,1]' . $l;
$n = 1;
} else {
if ($i == $count - 1) {
$l = '[' . ++$n . ',Inf]' . $l;
} else {
$l = '{' . ++$n . '}' . $l;
}
}
}
}
unset($l);
foreach ($locale as $l) {
if (preg_match('/^\\{(\\d+?)\\}(.*)/', $l, $match) && $args[0] == $match[1]) {
$locale = $match[2];
unset($args[0]);
break;
} else {
if (preg_match('/^\\[(\\d+?),(\\d+?|Inf)\\](.*)/', $l, $match) && $args[0] >= $match[1] && ($match[2] == 'Inf' || $args[0] <= $match[2])) {
$locale = $match[3];
unset($args[0]);
break;
}
}
}
if (is_array($locale)) {
return FALSE;
}
}
array_unshift($args, $locale);
return call_user_func_array('sprintf', $args);
}
示例4: callFunction
public static function callFunction( $name, $args, $context, $line ) {
if( !in_string( '_', $name ) ) {
$context->error( 'unknownfunction', $line, array( $name ) );
}
list( $prefix, $realName ) = explode( '_', $name, 2 );
$module = self::getModule( $prefix );
if( !$module || !in_array( $realName, $module->getFunctionList() ) ) {
$context->error( 'unknownfunction', $line, array( $name ) );
}
return $module->callFunction( $realName, $args, $context, $line );
}
示例5: runHook
/**
* Search for hook functions and run them if defined
*
* @param string $hook_name Name of hook to search for
* @param array $args Arguments to pass to the hook function
* @throws HookError
* @throws BadEntryError
* @return mixed Output of hook function
*/
public static function runHook($hook_name, $args = array())
{
global $pgHooks;
if (!isset($pgHooks[$hook_name])) {
return null;
}
if (!is_array($pgHooks[$hook_name])) {
throw new HookError("Hook assignment for event `{$hook_name}` is not an array. Syntax is " . '$pgHooks[\'hookname\'][] = "hook_function";');
}
$method = null;
foreach ($pgHooks[$hook_name] as $function) {
if (is_array($function)) {
if (count($function) < 2) {
throw new HookError("Not enough parameters in array specified for `{$hook_name}` hook");
} elseif (is_object($function[0])) {
$object = $function[0];
$method = $function[1];
if (count($function) > 2) {
$data = $function[2];
}
} elseif (is_string($function[0])) {
$method = $function[0];
if (count($function) > 1) {
$data = $function[1];
}
}
} elseif (is_string($function)) {
$method = $function;
}
if (isset($data)) {
$args = array_merge(array($data), $args);
}
if (isset($object)) {
$fncarr = array($object, $method);
} elseif (is_string($method) && in_string("::", $method)) {
$fncarr = explode("::", $method);
} else {
$fncarr = $method;
}
//is_callable( $fncarr ); //Apparently this is a bug. Thanks, MW!
if (!is_callable($fncarr)) {
throw new BadEntryError("MissingFunction", "Hook function {$fncarr} was not defined");
}
$hookRet = call_user_func_array($fncarr, $args);
if (!is_null($hookRet)) {
return $hookRet;
}
}
}
示例6: apply_labels
function apply_labels($dbh, $id, $user)
{
$labels = null;
$label_data = $dbh->prepare("SELECT * FROM cm_messages WHERE id = '{$id}'");
$label_data->execute();
$ld = $label_data->fetch(PDO::FETCH_ASSOC);
if (in_string($user, $ld['archive'])) {
$labels .= '<span class="label_archive">Archive</span>';
} else {
$labels .= '<span class="label_inbox">Inbox</span>';
}
if ($ld['from'] == $user) {
$labels .= '<span class="label_sent">Sent</span>';
}
return $labels;
}
示例7: jsonSerialize
public function jsonSerialize()
{
$fields = [];
$reflection = new \ReflectionClass($this);
foreach ($reflection->getMethods() as $method) {
if (substr($method->getName(), 0, 3) !== 'get') {
continue;
}
if (in_string("@JsonIgnore", $method->getDocComment())) {
continue;
}
$underscore = preg_replace('/([a-z])([A-Z])/', '$1_$2', substr($method->getName(), 3));
$fields[strtolower($underscore)] = $method->invoke($this);
}
return $fields;
}
示例8: getQuotesFromSearch
public function getQuotesFromSearch($search, $regex = false)
{
$retArr = array();
foreach ($this->quotes as $id => $quote) {
if ($regex) {
if (preg_match($search, html_entity_decode($quote))) {
$retArr[$id + 1] = $quote;
}
} else {
if (in_string($search, $quote, false) === true) {
$retArr[$id + 1] = $quote;
}
}
}
return $retArr;
}
示例9: __construct
public function __construct()
{
parent::__construct();
$this->_configs['base_url'] = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$this->_configs['request_url'] = $_SERVER['REQUEST_URI'] != $this->_configs['base_url'] ? substr($_SERVER['REQUEST_URI'], strlen($this->_configs['base_url'])) : 'index.html';
$this->_configs['extension_url'] = extension($this->_configs['request_url'], $this->_configs['request_url']);
$this->_configs['ajax_header'] = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
$ext = extension($url = !empty($_GET['request_url']) ? $_GET['request_url'] : $this->_configs['request_url'], $url);
$this->_configs['segments_url'] = explode('/', rtrim(substr($url, 0, -strlen($ext)), '.'));
if ($this->_configs['segments_url'][0] == 'admin') {
$this->_configs['admin_url'] = TRUE;
}
if (empty($this->_configs['admin_url']) && $this->_configs['segments_url'][0] == 'ajax' || !empty($this->_configs['admin_url']) && isset($this->_configs['segments_url'][1]) && $this->_configs['segments_url'][1] == 'ajax') {
$this->_configs['ajax_url'] = TRUE;
}
if (is_null($configs = NeoFrag::loader()->db->select('site, lang, name, value, type')->from('nf_settings')->get())) {
exit('Database is empty');
}
foreach ($configs as $setting) {
if ($setting['type'] == 'array') {
$value = unserialize(utf8_html_entity_decode($setting['value']));
} else {
if ($setting['type'] == 'list') {
$value = explode('|', $setting['value']);
} else {
if ($setting['type'] == 'bool') {
$value = (bool) $setting['value'];
} else {
if ($setting['type'] == 'int') {
$value = (int) $setting['value'];
} else {
$value = $setting['value'];
}
}
}
}
$this->_settings[$setting['site']][$setting['lang']][$setting['name']] = $value;
if (empty($site) && $setting['name'] == 'nf_domains' && in_string($_SERVER['HTTP_HOST'], $setting['value'])) {
$site = $value;
}
}
$this->update('');
$this->update('default');
if (!empty($site)) {
$this->update('default');
}
}
示例10: parse
public function parse($content, $data = array(), $loader = NULL, $parse_php = TRUE)
{
if (!$loader) {
$loader = $this->load;
}
if ($parse_php && is_callable($content)) {
$content = call_user_func($content, $data, $loader);
} else {
if (in_string('<?php', $content) && in_string('?>', $content)) {
$NeoFrag = $this->load;
$paths = $loader->paths;
$GLOBALS['loader'] = $loader;
//Récupèration du contenu du template avec exécution du code PHP
$content = eval('ob_start(); ?>' . preg_replace('/;*\\s*\\?>/', '; ?>', str_replace('<?=', '<?php echo ', $content)) . '<?php return ob_get_clean();');
}
}
return $content;
}
示例11: display
public static function display($disposition_id, $disposition, $page, $zone_id)
{
global $NeoFrag;
$output = display($disposition, NeoFrag::live_editor() ? $zone_id : NULL);
if (!NeoFrag::live_editor() && in_string('<div class="module', $output)) {
$output .= $NeoFrag->profiler->output();
}
if (NeoFrag::live_editor()) {
if (NeoFrag::live_editor() & NeoFrag::ZONES) {
$output = ' <div class="pull-right">
' . ($page == '*' ? '<button type="button" class="btn btn-link live-editor-fork" data-enable="0">' . icon('fa-toggle-off') . ' ' . $NeoFrag->lang('common_layout') . '</button>' : '<button type="button" class="btn btn-link live-editor-fork" data-enable="1">' . icon('fa-toggle-on') . ' ' . $NeoFrag->lang('custom_layout') . '</button>') . '
</div>
<h3>' . (!empty($NeoFrag->load->theme->zones[$zone_id]) ? $NeoFrag->load->theme->load->lang($NeoFrag->load->theme->zones[$zone_id], NULL) : $NeoFrag->lang('zone', $zone_id)) . ' <div class="btn-group"><button type="button" class="btn btn-xs btn-success live-editor-add-row" data-toggle="tooltip" data-container="body" title="' . $NeoFrag->lang('new_row') . '">' . icon('fa-plus') . '</button></div></h3>' . $output;
}
$output = '<div' . (NeoFrag::live_editor() & NeoFrag::ZONES ? ' class="live-editor-zone"' : '') . ' data-disposition-id="' . $disposition_id . '">' . $output . '</div>';
}
return $output;
}
示例12: delete
public static function delete($track_id)
{
if (empty($track_id)) {
throw new ControllerException("At lease one track id must be specified");
}
$track_ids = in_string(",", $track_id) ? explode(",", $track_id) : array($track_id);
self::validateListOfTrackIds($track_ids);
$track_objects = self::getTracksListById($track_ids);
$isTrackBelongsToUser = function ($track) {
return $track[TSongs::USER_ID] == self::$me->getId();
};
if (!$track_objects->all($isTrackBelongsToUser)) {
throw new ControllerException("One or more selected tracks is not belongs to you");
}
foreach ($track_objects as $track) {
Logger::printf("Removing track %s", $track[TSongs::ID]);
self::removeFilesUsedByTrack($track);
}
self::deleteTracksById($track_ids);
}
示例13: getBlameResult
function getBlameResult(&$pageClass, $text)
{
$history = $pageClass->history(null, 'older', true);
$list = '';
$anz = count($history);
foreach ($history as $id => $rev) {
if (in_string($text, $rev['*'], true) && ($id + 1 == $anz || !in_string($text, $history[$id + 1]['*'], true))) {
$date = date('Y-m-d, H:i ', strtotime($rev['timestamp']));
$year = date('Y', strtotime($rev['timestamp']));
$month = date('m', strtotime($rev['timestamp']));
$minor = $row['rev_minor_edit'] == '1' ? '<span class="minor" >m</span>' : '';
$list .= '
<tr>
<td style="font-size:95%; white-space:nowrap;">' . $date . ' · </td>
<td>(<a href="//{$domain}/w/index.php?title={$urlencodedpage}&diff=prev&oldid=' . $rev['revid'] . '" title="' . $title . '">diff</a>)</td>
<td>(<a href="//{$domain}/w/index.php?title={$urlencodedpage}&action=history&year=' . $year . '&month=' . $month . ' " title="' . $title . '">hist</a>)</td>
<td><a href="//{$domain}/wiki/User:' . $rev['user'] . '" title="User:' . $rev['user'] . '">' . $rev['user'] . '</a> </td>
<td style="font-size:85%" > · ' . htmlspecialchars($rev['comment']) . '</td>
</tr>
';
}
}
return $list;
}
示例14: isCountable
/**
* Determine whether a page would be suitable for being counted as an
* article in the site_stats table based on the title & its content
*
* @param $text String: text to analyze
* @return bool
*/
public function isCountable($text)
{
global $wgUseCommaCount;
$token = $wgUseCommaCount ? ',' : '[[';
return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token, $text);
}
示例15: test_in_string
/**
* @dataProvider provide_in_string
* @covers ::in_string
* @param $needle
* @param $haystack
* @param $insensitive
* @param $expected
*/
public function test_in_string($needle, $haystack, $insensitive, $expected)
{
$this->assertEquals($expected, in_string($needle, $haystack, $insensitive));
}