@ 2021-01-17T08:55:26Z <?php
class StringLike {
public $value;
public function __construct($value) {
$this->value = $value;
}
public function __toString() {
return $this->value;
}
}
$haystack = new StringLike('foo');
$needle = 'o';
echo mb_strlen($haystack), "\n";
echo mb_strpos($haystack, $needle), "\n";
$haystack = 123;
$needle = 2;
echo mb_strlen($haystack), "\n";
echo mb_strpos($haystack, $needle), "\n";
$haystack = null;
$needle = 'bar';
echo mb_strlen($haystack), "\n";
echo mb_strpos($haystack, $needle), "\n";
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.1.0 - 8.1.33 , 8.2.0 - 8.2.29 , 8.3.0 - 8.3.26 , 8.4.1 - 8.4.13 3
1
3
1
Deprecated: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /in/bh9aV on line 30
0
Deprecated: mb_strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/bh9aV on line 31
Output for 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 3
1
3
1
0
preferences:dark mode live preview ace vim emacs key bindings
181.99 ms | 407 KiB | 5 Q