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 $uri = isset($argv[1]) ? $argv[1] : 'www.google.com';
if (strpos($uri, '://') === false) {
$uri = 'http://' . $uri;
}
$parts = parse_url($uri);
<?php $pos = \strrpos($address, ':');
if ($pos !== false && \strpos($address, ':') < $pos && \substr($address, 0, 1) !== '[') {
$address = '[' . \substr($address, 0, $pos) . ']:' . \substr($address, $pos + 1); // @codeCoverageIgnore
}
<?php public function connect($uri)
{
$scheme = 'tcp';
if (\strpos($uri, '://') !== false) {
$scheme = (string)\substr($uri, 0, \strpos($uri, '://'));
}
<?php {
$scheme = 'tcp';
if (\strpos($uri, '://') !== false) {
$scheme = (string)\substr($uri, 0, \strpos($uri, '://'));
}
if (!isset($this->connectors[$scheme])) {
<?php $uri .= $parts['scheme'] . '://';
}
if (\strpos($ip, ':') !== false) {
$uri .= '[' . $ip . ']';
} else {
<?php public function connect($uri)
{
$original = $uri;
if (\strpos($uri, '://') === false) {
$uri = 'tcp://' . $uri;
$parts = \parse_url($uri);
if (isset($parts['scheme'])) {
<?php $pos = \strrpos($address, ':');
if ($pos !== false && \strpos($address, ':') < $pos && \substr($address, 0, 1) !== '[') {
$address = '[' . \substr($address, 0, $pos) . ']:' . \substr($address, $pos + 1); // @codeCoverageIgnore
}
<?php $that->failureCount++;
$message = \preg_replace('/^(Connection to [^ ]+)[&?]hostname=[^ &]+/', '$1', $e->getMessage());
if (\strpos($ip, ':') === false) {
$that->lastError4 = $message;
$that->lastErrorFamily = 4;
} else {
<?php public function connect($uri)
{
$original = $uri;
if (\strpos($uri, '://') === false) {
$uri = 'tcp://' . $uri;
$parts = \parse_url($uri);
if (isset($parts['scheme'])) {
<?php return Promise\reject(new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)')); // @codeCoverageIgnore
}
if (\strpos($uri, '://') === false) {
$uri = 'tls://' . $uri;
}
<?php );
$scheme = 'tcp';
$pos = \strpos($uri, '://');
if ($pos !== false) {
$scheme = \substr($uri, 0, $pos);
}
<?php );
$scheme = 'tcp';
$pos = \strpos($uri, '://');
if ($pos !== false) {
$scheme = \substr($uri, 0, $pos);
}
<?php {
if (\function_exists('socket_strerror')) {
foreach (\get_defined_constants(false) as $name => $value) {
if (\strpos($name, 'SOCKET_E') === 0 && \socket_strerror($value) === $errstr) {
return $value;
}
}
<?php {
if (\function_exists('socket_strerror')) {
foreach (\get_defined_constants(false) as $name => $value) {
if ($value === $errno && \strpos($name, 'SOCKET_E') === 0) {
return ' (' . \substr($name, 7) . ')';
}
}
<?php $error = \str_replace(array("\r", "\n"), ' ', $errstr);
if (($pos = \strpos($error, "): ")) !== false) {
$error = \substr($error, $pos + 3);
}
});