top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

In PHP strlen is returning +1 more than it should

0 votes
34 views

Trying to manage line breaks in some output I'm generating and using strlen to measure the lengths of the strings I'm printing. Discovered something strange (to me!) in that strlen is returning +1 more than it
should.

The strings are from a query of my database - simple name fields. But everyone of them is coming back with a length that is one more than I see.

posted Jul 5, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote

Doesn't work for me.

php > var_dump("Mike Hall", strlen("Mike Hall"));
string(9) "Mike Hall"
int(9)

Try trimming it first and then apply strlen.

answer Jul 5, 2013 by anonymous
Why would I need to trim something that I can already see doesn't have  any trailing or leading characters?
Because there are characters you can't see?
Similar Questions
+2 votes

I wrote a script, but when searched brings only one set of results. How do I make it so if there is more than one result, it will display them all?

+1 vote

I have a code in PHP something like this

 if (strlen($profile['current-employer']) == 0)
     break;
 else
     return a;

Now in some cases $profile['current-employer'] can be non-existent, now here my question is in the case of non-existent variable what strlen will result... (This is related with QueryHome code)

+1 vote

What are the perceived advantages of one over other while deciding to choose the Web development technology, considering all aspects right from design to hosting.

+3 votes

During the bench mark Drive test with other operator, we observe that in my network Rank 2 distribution is only 30% while in other operator is 60%.

can you help me what can be the possible causes for this?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...