php - I am getting error while calculating the length of a string -


i trying calculate length of string without using library function(for learning purpose). using following code:

<?php  $name = "mohammad umar"; $i=0; while($name[$i] != ''){     $i++; } echo $i++; ?> 

but getting error this:

notice: uninitialized string offset: 13 in c:\xampp\htdocs\form\test.php on line 4

i have initialized $i, why saying uninitialized string offset? there better way calculate length of string without library function, please suggest me.

without using strlen function this

$name = "mohammad umar"; $i=0; while(isset($name[$i])){     $i++; } 

Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -