title: How to return values in a function in php?
body: <p>I recently started working with PHP and I am trying to create a function that will return the content what I want to show. So that means I need to store the value of these contents in a variable in each case block and then return that variable value at the end.</p>
  
  <pre><code>&lt;?php
      function sidebarContent($id) {
          switch ($id) {
              case "21":
                  // how to store these values in a variable
                  &lt;p&gt;Hello ABC.&lt;/p&gt;
                  &lt;p class="content-register"&gt;&lt;a href="/abc"&gt;Abc&lt;/a&gt;&lt;/p&gt;
                  break;
              case "31":
                  // how to store these values in a variable
                  &lt;p&gt;Hello DEF.&lt;/p&gt;
                  &lt;p class="content-register"&gt;&lt;a href="/Def"&gt;Def&lt;/a&gt;&lt;/p&gt;  
                  break;
              case "41":
                  // how to store these values in a variable              
                  echo "Your favorite color is green!";
                  &lt;p&gt;Hello GHI.&lt;/p&gt;
                  &lt;p class="content-register"&gt;&lt;a href="/Ghi"&gt;Ghi&lt;/a&gt;&lt;/p&gt;          
                  break;
              default:
                  // how to store these values in a variable              
                  &lt;p&gt;Hello World.&lt;/p&gt;
          }
  
          // how do I return content here?
      }
  
      // call above function to test out
  ?&gt;
  </code></pre>
  
  <p>I am not able to understand how to store content values in a variable and then return at the end?</p>