Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php $email = ' user@example.com '; // Trim whitespace echo trim($email); // "user@example.com" echo ltrim($email); // "user@example.com " echo rtrim($email); // " user@example.com" $haystack = 'The quick brown fox'; // strpos — returns int|false $pos = strpos($haystack, 'quick'); if ($pos !== false) { echo "Found at position: $pos"; // 4 } // str_contains — PHP 8+ boolean if (str_contains($haystack, 'fox')) { echo 'Fox is present'; } // str_starts_with / str_ends_with (PHP 8+) var_dump(str_starts_with($haystack, 'The')); // bool(true) var_dump(str_ends_with($haystack, 'fox')); // bool(true)
Result
Open