(php)我对strcmp()的理解是否正确?

时间:2015-07-30 17:25:35

标签: php html strcmp

protected void doPost(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException
{
    processRequest(request, response); // data is processed in this method

    RequestDispatcher oRD = request.getServletContext().getRequestDispatcher("/displayResult.jsp");
    oRD.forward(request, response);
}

输出:

print("ABCDEF , ABC : " . strcmp("ABCDEF" , "ABC"));
print("ABC , ABCDEF : " . strcmp("ABC" , "ABCDEF"));

ABCDEF , ABC : 3 
ABC , ABCDEF : -3 

然后当A-D不为0时,它在A处停止。

ASCII值:

strcmp("ABCDEF" , "ABC") : 
A-A = 65-65 = 0, 
B-B = 66-66 = 0, 
C-C = 67-67 = 0,
D-A = 68-65 = 3, 

我理解strcmp()是否正确? ,我刚从互联网上了解到这个功能。

1 个答案:

答案 0 :(得分:-1)

if(strcmp("Taco", "Taco") == 0) {
 //This would return true. If the two words did not match, it would return false.
}

if(strcmp("Taco", "Taco") != 0) {
 //This would return false. If the two words did not match, it would return true.
}