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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -