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

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -