← CodePrimer
PHP
Beginner
Basics
Common PHP string functions
How do I count, reverse, or replace text?
strlen, strpos, str_replace…
<?php
$text = 'Web Development';
echo strlen($text);
echo str_word_count($text);
echo strrev($text);
echo strpos($text, 'Dev');
echo str_replace('Web', 'App', $text);
Notes
strpos returns false when not found — check with ===.
Keywords: strlen · strpos · str_replace · strrev · string
Related
HTML
HTML headings h1–h6
How do I create page headings?
CSS
Three ways to apply CSS
What are inline, internal, and external CSS?
PHP
Embed PHP inside HTML
How do I mix PHP and HTML?
HTML
Paragraphs and line breaks
How do I break text into paragraphs?
CSS
CSS box model
Why is my element wider than expected?
PHP
PHP comments
How do I write comments in PHP?