2012-01-11 2 views
0

SOLVED 여러분의 의견에 감사드립니다. 매우 감사.간단한 PHP 구문 문제

누구나 간단한 구문 문제를 해결할 수 있다면 큰 도움이 될 것입니다. 난 아직 PHP의 학습 단계에있어 단지 이것을 알아낼 수 없습니다. 다음 코드에서는 배열과 정의를 할당하고 있지만 정보를 반향하려고하면 다시 작동하지 않습니다.

$arr_features=array("PasswordProtect"); 

    $arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: "echo ($_POST['PasswordProtect']);""); 

기본적으로 "암호 :"부분이 작동하지 않습니다. 이유가 무엇입니까? 미리 감사드립니다.

+3

"작동하지 않습니다"는 결코 좋은 오류 설명이 아닙니다. 대신 무엇이 잘못되었는지, 어떤 오류 메시지를 받았는지 등에 대해 설명하십시오. –

+0

그게 문제입니다. 오류 메시지가 표시되지 않습니다. 에코 부분없이 정상적으로 진행되는 확인 페이지로 이동하는 대신 빈 화면 만 제공합니다. – NewB

+0

[오류보고 사용] (http://kb.siteground.com/article/How_to_enable_error_reporting_in_a_PHP_script.html). 그러면 문제가 무엇인지 알 수 있습니다. 항상 문제에 대한 해결책을 제시하지는 않지만 어떤 라인에서 문제가 발생하는지 알려줄 것입니다. –

답변

2

당신이 PHP 학습되어 있기 때문에 :

echo()가 출력 렌더링 된 HTML에 문자열. 다른 문자열의 끝에 문자열을 추가하거나 추가하려면 문자열 연결 연산자 인 . (예 : 점)을 사용하여 연결해야합니다. 당신의 예에서

, 그것은된다 : 이 $arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: " . $_POST['PasswordProtect']);

1

$arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: " . $_POST['PasswordProtect']);

1

당신이 문자열에서 문을 포함하려고하기 때문에.

$arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: " . $_POST['PasswordProtect']); 

또는 중괄호 {} : : 문자열을 출력하려면 올바른 코드

1
$arr_features=array("PasswordProtect"); 

$arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: ".$_POST['PasswordProtect']); 

오히려, 당신은 . 연결 연산자를 사용할 필요가

$arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: {$_POST['PasswordProtect']}"); 
1

에게 변수의 올바른 구문

$arr_FeaturesDescriptions = array("Password Protection: Password Protection will be enabled, requiring participants to enter a password in order to access the event. Your password is: {$_POST['PasswordProtect']}"); 
1

$ _POST의 데이터를 필터링 한 다음 코드에서 사용해야합니다.

$passwordprotect = validate_input($_POST['PasswordProtect']); 
$arr_features=array("PasswordProtect"); 
$arr_FeaturesDescriptions = array("Password Protection: ... Your password is: $passwordprotect"); 

을하지만 당신은 정말 관계없이 일반 텍스트 암호를 표시해서는 안됩니다 : 당신이 따옴표를 사용하고 있기 때문에, 당신은 쉽게 내에서 변수를 평가합니다 PHP에서 따옴표 문자열 때문에 변수 이런 식으로 삽입 할 수 있습니다.

1

보다는 echo(), 당신은 string concatenation를 사용해야합니다. $_POST['PasswordProtect']을 인용 된 문자열에 중괄호 ({})로 묶거나 문자열 끝에 '.'기호를 추가 할 수 있습니다. 운영자.

다음은 php.net의 string data type documentation에 대한 링크로 PHP에서 문자열을 다룰 수있는 여러 가지 방법을 자세히 설명합니다.