473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Probs with strlen ??

Hello,

I'm doing like this:

if (strlen($Name_vor) > 0)
echo '</table></fieldset>';
But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vor) before the condition and it is definivly
0

From te manual strlen returns an INT.

What is wrong ??

TIA

Hanjo
--
Software & Seminar-Kontor Hans-Joachim Grüßner
Glasholz
D-24369 Waabs
http://www.gruessner.de
Aug 28 '05 #1
6 1576
Hanjo Grüßner wrote:
Hello,

I'm doing like this:

if (strlen($Name_vor) > 0)
echo '</table></fieldset>';
But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vor) before the condition and it is
definivly
0


There might be a previous condition overwriting this one. BTW, as anything
above 0 evaluates as TRUE in PHP, you could simply do:

if (strlen($Name_vor))
echo '</table></fieldset>';

Or even:

if ($Name_vor)
echo '</table></fieldset>';
JW

Aug 28 '05 #2
max
On Sun, 28 Aug 2005 13:41:34 +0200, Hanjo Grüßner <ha***@gruessner.de>
wrote:
Hello,

I'm doing like this:

if (strlen($Name_vor) > 0)
echo '</table></fieldset>';
But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vor) before the condition and it is definivly
0

From te manual strlen returns an INT.

What is wrong ??

TIA

Hanjo

If you're just checking that $Name_vor has a length (and, thus, that it
exists) can you not go -

if ($Name_vor) do_such_and_such;

Have you had a look at www.php.net/strlen ? One of the contributions there
helped me solve a problem -

QUOTE
Beware: strlen() counts new line characters at the end of a string, too!

$a = "123\n";
echo "<p>".strlen($a)."</p>";

The above code will output 4.
UNQUOTE
Aug 28 '05 #3
On Sun, 28 Aug 2005 13:41:34 +0200, Hanjo Grüßner <ha***@gruessner.de> wrote:
I'm doing like this:

if (strlen($Name_vor) > 0)
echo '</table></fieldset>';

But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vor) before the condition and it is definivly
0


From te manual strlen returns an INT.

What is wrong ??


Can you post a minimal test case reproducing the problem?

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 28 '05 #4
On Sun, 28 Aug 2005 12:28:56 GMT, max <ma****@homtail.com> wrote:
If you're just checking that $Name_vor has a length (and, thus, that it
exists) can you not go -

if ($Name_vor) do_such_and_such;


Not the same. Consider: $Name_vor = '0';

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 28 '05 #5
Am Sun, 28 Aug 2005 14:38:00 +0200 schrieb Andy Hassall <an**@andyh.co.uk>:

Can you post a minimal test case reproducing the problem?


Thanks, I found the mistake - as stupid as it could be:

I wrote $Name_vor instead of $Name_Vor

Greetings from the sunny shores of the baltic sea

Hanjo
--
Software & Seminar-Kontor Hans-Joachim Grüßner
Glasholz
D-24369 Waabs
http://www.gruessner.de
Aug 28 '05 #6
=?iso-8859-15?Q?Hanjo_Gr=FC=DFner?= <ha***@gruessner.de> wrote:
Thanks, I found the mistake - as stupid as it could be:
I wrote $Name_vor instead of $Name_Vor


You have learnt your lesson well grasshopper. Switch on all errors and
warnings and declare your variables before using them.

Bill, fwsh fwsh.

--
http://billpg.me.uk/ usenet(at)billpg(dot)me(dot)uk
Aug 28 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Arijit Chatterjee | last post by:
Hi Everybody, I am facing another probs. I have created a trigger for table Tab1 for perticular column col1 for checking value ranges.But at time for using insert statement it is working fine but...
21
by: sugaray | last post by:
hi, it just came up my mind that since we can get the length of any given string literal S with 'sizeof S-1', so, what's the merit of library function strlen()'s existence ? thanx in advance for...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
33
by: apropo | last post by:
what is wrong with this code? someone told me there is a BAD practice with that strlen in the for loop, but i don't get it exactly. Could anyone explain me in plain english,please? char...
66
by: roy | last post by:
Hi, I was wondering how strlen is implemented. What if the input string doesn't have a null terminator, namely the '\0'? Thanks a lot Roy
83
by: rahul8143 | last post by:
hello, what is difference between sizeof("abcd") and strlen("abcd")? why both functions gives different output when applied to same string "abcd". I tried following example for that. #include...
2
by: Chris | last post by:
Hi there, I have been reading in this group for a while really enjoy this pool of infinite c wisdom. :) Anyway, I have question now. I have this little piece of code that is giving me a...
53
by: ¬a\\/b | last post by:
strlen is wrong because can not report if there is some error e.g. char *a; and "a" point to an array of size=size_t max that has no 0 in it
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.