2014-10-07 4 views
0
session_start(); //continue session 

$courseArray = array(); //create array to store current course info 
$courseArray = $_SESSION['course']; //fill array 

$currentTitle = (string)$courseArray[0][0];  
$currentDescription = (string)$courseArray[0][1];  
$currentRecPrep = (string)$courseArray[0][14]; 

$newTitle = (string)$_POST["title"]; 
$newDescription = (string)$_POST["description"]; 
$newRecPrep = (string)$_POST["recPrep"]; 

if($currentTitle == $newTitle) 
{ 
echo "succuse"; 
} 

위 코드는 이전 페이지에 제출 된 양식에서 데이터를 가져 와서 사용자가 제출 한 데이터가 이미 세션 변수에 저장된 데이터와 다른지 확인합니다 . 제목, 설명 및 recPrep을 다른 페이지에서 보내고 올바른 값을 제출하고 있습니다.연산자가 완료되지 않은 경우 PHP

지난 한 시간 동안 머리카락을 꺼내는 부분이 있습니다. 비교되는 문자열은 동일하지만 조건이 완료되지 않습니다. 조건 앞에서 두 개의 제목을 출력하면 정확하게 똑같은 것을 인쇄하지만 조건은 완료되지 않습니다. 뭐가 잘못 되었 니?

누군가 도와주세요. 감사. 작동하지 않았다

if (strcmp($currentTitle, $newTitle) === 0) { 
    echo "succuse"; 
} else { 
    echo '$currentTitle is not equal to $newTitle in a case sensitive string comparison'; 
} 

답변

1

는 === 연산자로 strcmp와 기능을 사용해보십시오. 몰래 들어간 하나의 공간이있었습니다.
+0

감사합니다,하지만 난 반향 때 결과 1 내놓았다 : – user1834616

관련 문제