php post变量由关键字optional包围

php post变量由关键字optional包围,php,ios,xcode,swift,Php,Ios,Xcode,Swift,有没有一种方法可以在php中剥离发布的变量,或者通过swift以不同的方式发送它,这样关键字optional就不会围绕该变量了 例如: $username = $_POST['username']; $query = "SELECT username from users where username = '".$username."' "; //when echo query output is: SELECT username from users where username = 'O

有没有一种方法可以在php中剥离发布的变量,或者通过swift以不同的方式发送它,这样关键字optional就不会围绕该变量了

例如:

$username   = $_POST['username'];
$query = "SELECT username from users where username = '".$username."' ";
//when echo query output is: SELECT username from users where username = 'Optional("t")' 
//I need to remove Optional so query outputs:
// "SELECT username from users where username = 't'
我在swift中输入参数,如下所示:

var post:NSString = "username=\(username)"    
NSLog("PostData: %@",post);

您可以使用以下方法来完成此操作:

var post: NSString = "username=\(username!)"

但是,如果由于某种原因,
username
为零,则应用程序将崩溃。你可以把它围成一个
如果…让
来避免它

没问题@SlopTonio如果你能接受我的答案那就太好了!是的,我正在等待15分钟的窗口到期,因此stackoverflow将允许我接受答案