str_replace — Replace all occurrences of the search string with the replacement string. Example for str_replace() <?php echo str_replace("world","siva","Hello world!"); ?> substr_replace - The function substr_replace introduces some additional functionality to compliment str_replace. substr_replace is a more mathematically based replace function, which relies on starting points and lengths to replace parts of strings, as opposed to searching and replacing.