title: Why does this function generate an uninitialized string offset notice?
body: <p>I'm having this error when I run my program:</p>
  
  <blockquote>
    <p>Notice: Uninitialized string offset: 7 in C:\xampp\htdocs\demo\str_rev.php on line 21</p>
  </blockquote>
  
  <p>What causes that?</p>
  
  <pre><code>&lt;?php
  
      //strrev($arg);
      /*$str = "ademola";
      echo strrev("$str");
      */
  
      function reverse_String($str){
          $i = 0;
          while(!empty($str[$i])){
              echo $str[$i];
                  $i++;
          }
  
  
          for($r = $i; $r &gt; -1; $r--){
              $reverse = $str[$r];
              echo $reverse;
  
          }
      }
  
      reverse_String("Ademola");
  ?&gt;
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>Ademola<br>
    <code>Notice: Uninitialized string offset: 7 in C:\xampp\htdocs\demo\str_rev.php on line 21</code><br>
    alomedA</p>
  </blockquote>