Empty string? How can I check?
I'm building up a plugin that saves data into a file. The problem is with the number of arguments. I'm trying to save 4 values (IT WORKS) but, If I execute the command with 3 values, the data line is also created, but with 3 values I can't make anything (for different functions). Anyway... this is the code:
PHP Code:
|
Re: Empty string? How can I check?
Title says a different thing... but anyway: if(strlen(string) > 0) or just if(string[0]) to check an empty string.
About the arguments, you can get all arguments stacked together with read_args() if you're just going to add all of them like that anyway. And about less than 4 arguments, you should modify cmd_access()'s 4th argument to 1, that sets the required number of arguments, that's why you can't use less. |
Re: Empty string? How can I check?
I think the answer to your question lies here: When using cmd_access() the command itself is considered an argument. If you want it to require 4 arguments be provided by the user with the command then you need to change the 4 to 5.
P.S. What is up with your title? A little misleading :). |
Re: Empty string? How can I check?
read_argv() returns the number of characters in the string.
Just check if that is 0. |
Re: Empty string? How can I check?
My bad, because I post so quickly. I wanted to check if argument 4 is empty. If is empty than the function is returned.
PHP Code:
Edit: I found the answer ! PHP Code:
|
Re: Empty string? How can I check?
read_argv(4, argFour, 31) already returns the length, as xolent already told you.
Please read people answers ;) |
Re: Empty string? How can I check?
Why not do this:
PHP Code:
|
Re: Empty string? How can I check?
I think that if you pass "" as argument, it could be counted, not sure though.
|
Re: Empty string? How can I check?
Quote:
|
Re: Empty string? How can I check?
Quote:
So, every function that uses cmd_access() without checking arg length of all arguments has a potential breaking point :). |
| All times are GMT -4. The time now is 04:31. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.