Jump to content

Undefined String Offset.


atrum

Recommended Posts

Ok, I am sure you have all come across this error before.

I am trying to understand why this occurs in a straight forward (spelled out for the complete dumb ass) kind of way.

 

I made the most simple script I could come up with that would produce the error, but I am still uncertain as to what causes it, or what the fix is.

 

 

Here is the script.

Using all the letters and numbers available I print the total characters in the string, run a for statement to print out each character in order from the string index, and get the error "Undefined String Offset 36". Which is the total number of characters in the string starting at 0.

The test script can be accessed at the following url: http://icca.exiled-alliance.com/classtest.php

$test = "abcdefghijklmnopqrstuvwxyz1234567890";
$b = "<br />";
echo $test;
echo $b;
echo "There are " .strlen($test). " characters in the above string";
echo $b;
for($x=0;$x<=strlen($test);$x++){
echo $test[$x]. "-->number $x";
echo $b;
}

 

Can anyone clear up why that error pops up from the way I have this scripted.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.