title: Fatal error: Array and string offset access syntax with curly braces is no longer supported in php 8.0 pkcs5_unpad
body: <p>I got this error after copying code from a tutorial. It's deprecated and I tried resolving it:</p>
  <blockquote>
  <p>Array and string offset access syntax with curly braces is no longer supported in .../app/Http/Helpers/helpers.php</p>
  </blockquote>
  <p>My code copy:</p>
  <pre class="lang-php prettyprint-override"><code>if (!function_exists(&quot;pkcs5_unpad_e&quot;)) {
      function pkcs5_unpad_e($text) {
          $pad = ord($text{strlen($text) - 1});
          if ($pad &gt; strlen($text))
              return false;
  
          return substr($text, 0, -1 * $pad);
      }
  }
  </code></pre>
  <p>My edit: replace <code>{....}</code> with <code>[.....]</code> ==&gt; HTTP ERROR 500</p>
  <pre class="lang-php prettyprint-override"><code>if (!function_exists(&quot;pkcs5_unpad_e&quot;)) {
      function pkcs5_unpad_e($text) {
          $pad = ord($text[strlen($text) - 1]);
          if ($pad &gt; strlen($text))
                  return false;
              
          return substr($text, 0, -1 * $pad);
      }
  }
  </code></pre>
  <p>I am using Ubuntu 20.04 DigitalOcean Cyberpanel server and PHP 8.</p>