title: PHP -- How to replace string value to user input?
body: <p>Can someone help me to figure out how to replace a defined string value with user input value? I am quite new in PHP programming and could not find an answer. I saw a lot of ways to replace string on the internet by using built-in functions or in arrays, but I could not find out the right answer to my question.</p>
  <p>Here is my code:</p>
  <pre><code>$text = &quot;Not found&quot;;
  if ( isset($_GET['user'])) {
     $user_input = $_GET['user']; 
  }
  </code></pre>
  <p>// from here I I tried to replace the value $text to user input, but it does not work.</p>
  <pre><code>    $raw = TRUE;
      $spec_char = &quot;&quot;;
      if ($raw) {
         $raw = htmlentities($text);
         echo &quot;&lt;p style='font-style:bold;'&gt; PIN &quot; . $raw . &quot;&lt;/p&gt;&quot;;  *# displays &quot;Not found&quot;*
      } elseif (!$raw == TRUE ) {   
         $spec_char = htmlspecialchars($user_input);  
         echo &quot;&lt;p&gt;PIN  $spec_char &lt;/p&gt;&quot;;   
      }
  
  &lt;form&gt;
     &lt;input type=&quot;text&quot; name=&quot;user&quot; size=&quot;40&quot; /&gt;
     &lt;input type=&quot;submit&quot; value=&quot;User_val&quot;/&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I appreciate your answers.</p>