把字符串 "Hello world!" 中的字符 "world" 替换为 "Shanghai":
<?php echo str_replace("world","Shanghai","Hello world!"); ?>