Laravel 5.1 GeoIP非静态方法不应该静态调用,假设$ this来自不兼容的上下文

时间:2015-11-28 15:49:42

标签: php geolocation laravel-5.1 geoip

我正在使用Torann \ GeoIP当我尝试

时出现此错误
import random
score = 0
questions = 0
classnumber = ("1","2","3")
name= input("Enter Your Username: ")
print("Hello, " + name+(". Welcome to the Arithmetic Quiz")

classno = input("What class are you in?"))
    while group not in classnumber:
        print("Enter a valid class")
        classno=input("What class are you in?")

while questions <10:
    for i in range(10):
        number1=random.randint(1,10)
        number2=random.randint(1,10)
        op=random.choice("*-+")
        multiply=num1*num2
        subtract=num1-num2
        addition=num1+num2

        if op == "-": 
            print("Please enter your answer.")
            questions+=1
            print(" Question" ,questions, "/10")
            uinput=input(str(number1)+" - "+str(number2))
            if uinput == str(subtract):
                score+=1
                print("Correct, your score is: " ,score,)
            else:
                print ("Incorrect, the answer is: " +str(subtract))
                score+=0

        if op == "+":
            print("Please enter your answer.")
            questions+=1
            print(" Question",questions, "/10")
            uinput=input(str(number1)+" + "+str(number2))
            if uinput == str(addition):
                score+=1
                print("  Correct, your score is: ",score,)
            else:
                print("  Incorrect, the answer is: " +str(addition))
                score+=0

        if op == "*":
            print("Please enter you answer.")
            questions+=1
            print(" Question",questions, "/10")
            uinput=input(str(number1)+" * "+str(number2))
            if uinput == str(multiply):
                score+=1
                print("  Correct, your score is: " ,score,)
            else:
                print("  Incorrect, the answer is: " +str(multiply))
                score+=0

if score >9:
    print("Well done," ,name1, "your score is" ,score, "/10")
else:
 print(name1," your score is " ,score, "/10")

def no1():
     with open("class1.txt", 'a')as file:
         file.write(str(name1)+str( score)+"\n")
def no2():
     with open("class2.txt", 'a')as file:
         file.write(str(name1)+str( score)+"\n")
def no3():
     with open("class3.txt", 'a')as file:
         file.write(str(name1)+str( score)+"\n")
if group=="1":
    no1()
if group=="2":
    no2()
if group=="3":
    no3()

但是当我尝试使用

    use Torann\GeoIP\GeoIP;
Route::get('geoip', function() {
    $location = GeoIP::getLocation();
});

我有这个错误&#39;参数1传递给Torann \ GeoIP \ GeoIP :: __ construct()必须是Illuminate \ Config \ Repository的一个实例,没有给出&#39;

所以我错过了__construct的参数.... $geo = new GeoIP(); $geo - getLogation(); 所以应该看起来像这样

$config, $session

但是我需要给$ config =?和$ session =?

任何siggestions都会有所帮助。谢谢

如果有更好的方法来获取GeoLocation数据,那就太棒了。

1 个答案:

答案 0 :(得分:-1)

您必须声明:

use Torann\GeoIP\GeoIPFacade as GeoIP;

并移动文件  /vendor/torann/geoip/src/config/geoip.php /config/geoip.php。{/ p>