Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Find the position of the first occurrence of a substring in a string
<?php strpos(string $haystack, string $needle, int $offset = 0): int|false
<?php public static function stripVariables($string)
{
if (\strpos($string, '$') === false) {
return $string;
}
<?php public function getFQName(File $phpcsFile, $stackPtr, $name)
{
if (\strpos($name, '\\') === 0) {
return $name;
}
<?php }
if (\strpos($name, 'namespace\\') === 0) {
$name = \substr($name, 10);
}
<?php public function isNamespaced($FQName)
{
if (\strpos($FQName, '\\') !== 0) {
throw new RuntimeException('$FQName must be a fully qualified name');
}
<?php throw new RuntimeException('$FQName must be a fully qualified name');
}
return (\strpos(\substr($FQName, 1), '\\') !== false);
}
<?php }
foreach ($this->removedExtensions as $extension => $versionList) {
if (\strpos($functionLc, $extension) === 0) {
$itemInfo = [
'name' => $extension,
];
<?php }
if (\is_string($this->functionWhitelist) === true) {
if (\strpos($this->functionWhitelist, ',') !== false) {
$this->functionWhitelist = \explode(',', $this->functionWhitelist);
} else {
$this->functionWhitelist = (array) $this->functionWhitelist;
<?php ];
$errorCode = 'ASPOpenTagFound';
} elseif (\strpos($content, '<script ') !== false) {
$data = [
'Script',
$content,
<?php if ($openTag['code'] === \T_INLINE_HTML && $this->aspTags === false) {
if (\strpos($content, '<%') !== false) {
$error = 'Possible use of ASP style opening tags detected. ASP style opening tags have been removed in PHP 7.0. Found: %s';
$snippet = $this->getSnippet($content, '<%');
$data = ['<%' . $snippet];
<?php $startPos = 0;
if ($startAt !== '') {
$startPos = \strpos($content, $startAt);
if ($startPos !== false) {
$startPos += \strlen($startAt);
}
<?php }
if (isset(BCTokens::textStringTokens()[$tokens[$i]['code']]) === true
&& \strpos($tokens[$i]['content'], '/>') !== false
) {
$phpcsFile->addError(
'Self-closing XHTML tags are ignored. Only non-self-closing tags should be used in the strip_tags() $allowable_tags parameter since PHP 5.3.4. Found: %s',
<?php continue;
}
if (\strpos($tokens[$i]['content'], 'c+') !== false && $this->supportsBelow('5.2.5')) {
$errors['cplusFound'] = [
'c+',
'5.2.5',
<?php '5.2.5',
$targetParam['clean'],
];
} elseif (\strpos($tokens[$i]['content'], 'c') !== false && $this->supportsBelow('5.2.5')) {
$errors['cFound'] = [
'c',
'5.2.5',
<?php ];
}
if (\strpos($tokens[$i]['content'], 'e') !== false && $this->supportsBelow('7.0.15')) {
$errors['eFound'] = [
'e',
'7.0.15',
<?php }
$paramName = '$encoding';
if (\strpos($functionLC, 'iconv_') === 0) {
$paramName = '$charset';
} elseif ($functionLC === 'mb_convert_encoding') {
$paramName = '$from_encoding';