<?php
$searchFor="the";
$replaceWith = "<span class=\"found\">".$word."</span>";
$sentence = "Hello, did you hear the quick brown fox jumped over the lazy dog";
$edited = str_replace($searchFor, $replaceWith, $sentence);
echo $edited;
Warning: Undefined variable $word in /in/neYiW on line 3
Hello, did you hear <span class="found"></span> quick brown fox jumped over <span class="found"></span> lazy dog
Notice: Undefined variable: word in /in/neYiW on line 3
Hello, did you hear <span class="found"></span> quick brown fox jumped over <span class="found"></span> lazy dog
Output for 7.3.32 - 7.3.33, 7.4.26
Hello, did you hear <span class="found"></span> quick brown fox jumped over <span class="found"></span> lazy dog
Notice: Undefined variable: word in /in/neYiW on line 3
Hello, did you hear <span class="found"></span> quick brown fox jumped over <span class="found"></span> lazy dog