ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am playing with PHP trying to get any 3 inputs from the user and then compute the simple interest from what that person puts in. I have so far the following
basically I am trying to either set up a loop of an if statement stating that if (3 variables are input) do this formula and so on and so forth....any help getting going would be much appreciated.
so what's the question? are you asking for a better method? or are you asking for the form that would submit these values? something else? There are a few typos in there & you should probably check more than one variable at a time using the && operator.
The function that you want is empty(). This will return true is the value is empty.
You will of course want to check that you have three valid values, you can do this by stepping through each variable and keeping a count of the number of number of non-empty once, so long as you have a total of three then you have valid input and so you can proceed.
Give it a go and if you have any problems get back.
@BrianK
If one knows the function name (as in this case), one does not need to search but can append it at the end of the URL (in this case http://www.php.net/empty).
Better even, if you do NOT know the exact function name, just add it like in http://www.php.net/mysql_affectedrows . It will tell you that it could not find it and give you a list of names that are close.
Hasn't failed me yet but might only be possible for english language.
where is this function empty? a tutorial maybe somewhere?....I have heard of this function but I haven't found much on it. how would you set that up?
As others have mentioned you can look up the details of empty() in the php manual, either the online version or if you have a local copy you can find it there.
Technically empty() is not a function but a construct of the language, but because it follows the syntax of a function lazy people like me call it a function. However because of this it does have some limitations all explained in the manual.
Finally, like many modern scripting languages (Perl, Python, Ruby and PHP all come to mind) are supported by a large collection of functions that are considered part of the language and are bundled by default with the language and yet more can be added as you need them. So a large part of learning the language is in understanding the functions that are available. My advice, once you are comfortable with the core language browse the manual just looking at the wide collection of function families that are available and then spend a little time looking at the function families that look useful or intriguing. An early investment in the array and string functions would be time well spent.
Ok I thought I was done...apparently not...I am still getting an error and I had some help with it. we wrote the code together then I copied it EXACTLY like it was on his when it worked....now that it is on my machine ....
Quote:
parse error, unexpected T_VARIABLE on line 28
I have no clue what is wrong. I am probably looking right at it and not seeing it..
here is line 29 up to the start of the actual PHP
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.