ふざけて、以下に記述された python 電卓プログラムを PHP に変換しようとしています。
誰でも私を助けることができますか/これは可能ですか?
プログラムは以下のとおりで、PHP を使用しても同じ出力を得たいと考えています。
#!/usr/bin/env python
#
#title: calculator.py
#author: Samuel Peppard
#purpose:
#
# 1 equates a loop, everything else does not.
loop = 1
# Contains the player's choice
choice = 0
while loop == 1:
# Print what options you have
print " "
print "Basic Calculator Program!"
print " "
print "Select your function by typing its designated number..."
print " "
print "1) Addition"
print "2) Subtraction"
print "3) Multiplication"
print "4) Division"
print "5) Quit"
print " "
# allows for raw input to be read
choice = int(raw_input("Choose your option: ").strip())
if choice == 1:
add1 = input("Add this amount: ")
add2 = input("to this amount: ")
print " "
print add1, "+", add2, "=", add1 + add2
elif choice == 2:
sub2 = input("Subtract this amount: ")
sub1 = input("from this amount: ")
print " "
print sub1, "-", sub2, "=", sub1 - sub2
elif choice == 3:
mul1 = input("Multiply this amount: ")
mul2 = input("with this amount: ")
print " "
print mul1, "*", mul2, "=", mul1 * mul2
elif choice == 4:
div1 = input("Divide this amount: ")
div2 = input("by this amount: ")
print " "
print div1, "/", div2, "=", div1 / div2
elif choice == 5:
loop = 0
print "Goodbye for now!"