2017-02-12 38 views
0

在我的程序中遇到一些PHP静态函数的问题。我的代码如下,我不断收到错误“预计的匿名函数”。我正在使用IDE PhpStorm。错误:在PHP中使用静态函数时预计会出现匿名函数

我已经有一个谷歌,但没有出现。如果我删除该函数的名称错误消失,但我不知道如何调用该函数。

<?php 

/** 
* @param mysqli $conn Connection to the database. 
* @param int $id The ID of the white card that is to be voted up. 
*/ 
public static function voteUp($conn, $id){ 
    mysqli_query($conn, 'UPDATE WhiteCards SET Ups = Ups + 1 WHERE ID = ' . $id); 
} 

/** 
* @param mysqli $conn Connection to the database. 
* @param int $id The ID of the white card that is to be voted down. 
*/ 
public static function voteDown($conn, $id){ 
    mysqli_query($conn, 'UPDATE WhiteCards SET Ups = Ups - 1 WHERE ID = ' . $id); 
} 
+2

你怎么称呼这些功能? – scaisEdge

+0

@scaisEdge OP:*“但我不知道如何调用函数”* ;-),这是任何人的猜测。 –

+0

@ Fred-ii-谢谢..我没有正确阅读..但如果“我删除函数的名称错误消失” – scaisEdge

回答

2

刚刚解决了它,这两个函数需要在一个类中。