Jump to content
xisto Community
Sign in to follow this  
iGuest

Php Script Without Parameters

Recommended Posts

Is it me not understanding or it's your question that's difficult to understand? :)How can anybody write calculator php script without calculator?Do you mean write a php script that makes calculations without using the windows calculator application?

Share this post


Link to post
Share on other sites

Is it me not understanding or it's your question that's difficult to understand? :)
How can anybody write calculator php script without calculator?

Do you mean write a php script that makes calculations without using the windows calculator application?


I'm going to guess that's what he's asking for. If that's the case, the easiest way to explain it is to look up operators, variables and output statements. Creating a calculator is very basic and should give you knowledge needed to build a more complex application.

Hint: you're setting a variable to 0 at the beginning, then incrementing/decrementing/multiplying/dividing it based on what button is clicked and what text is in the box.

Share this post


Link to post
Share on other sites

A PHP calculator script without a calculator? I don't get it - does it mean that it is supposed to be a script that can calculate without actually providing a calculator-like interface? Perhaps two text boxes and a button to keep it simple? Sounds like this is the case, though am not sure what the "without parameters" means in the thread topic.To put together a form on an HTML page, Adobe DreamWeaver can be used - it does not really need one to be familiar with HTML. Placing a form on the page is shown in DreamWeaver is a red box formed with a dashed or dotted line (I am not sure if the newer versions of DreamWeaver still work the same way and represent a form with the red dashed or dotted line). Let's just assume for this discussion that it is a red box formed with dased lines. Within the red dashed-line box, place the input text elements from within the Forms tab of the toolbox. Give the input text elements a name that you can use to reference it, such as txt1 and txt2. Then, select the form (red dashed box) and assign the action property of the form the name of a PHP file, such as calc.php. Within calc.php, the values from this form would be accessible within a $_REQUEST global associative array, so all you would need to do is access the elements of the array using the names of the input text elements as keys to retrieve the values. You can simply add them together because PHP automatically converts the strings into integers, and you can echo the sum of the two variables.

Share this post


Link to post
Share on other sites

I've spent some more time thinking about the "without parameters" thing myself. I've come up with the conclusion that it probably deals with being able to add/subtract/multiply/divide unlimited numbers, rather than saying "choose #1," "choose #2," etc. with a finite number. That's the only type of parameter I can really relate to the project.

Share this post


Link to post
Share on other sites

rpgsearcherz,

 

If that is the case, the calculator would be rather simple to build - by providing an HTML form input box to enter an expression, the user could enter something like: "3 * (1 + 4)"

What you can then do with that input is run it through the eval function to get the result and it is as simple as that! Now, experienced programmers would tell you about the security implications of it, in which case you would probably deal with it by having a security check on the input being entered to permit only digits, mathematical operators, and parentheses. Some web hosting servers may not provide access to the eval function but then again there is only so much you can do with a locked-down server without re-inventing the wheel.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.