2012-06-16 3 views
-2

가능한 중복 : 안녕하세요 팝업로 자신을 표시하는 PHP 변수를 만들려고하고
Creating javscript function to destroy php sessionPHP 변수

. 다음은 내가 가지고있는 코드입니다 ...

<?php 
// this starts the session 
session_start(); 
$var = ""; 

// echo variable from the session, we set this on our other page 
if ($_SESSION['color'] == "") { 
     $var = "<a href='JavaScript:newPopup('http://www.yourfantasyfootballreality.com/signin.php');' class='two'>Sign In</a>"; 
    } else { 
    echo "Hello, "; 
    } 
echo $var; 
?> 

세미콜론과 따옴표를 올바르게 정렬 할 수 없습니다. 누군가 어떻게 이것이 이루어 졌는지 보여 주실 수 있습니까? 당신은 이스케이프 문자 (\)와 문자열 내에서 문자열을 구분하기 위해 사용하는 인용 문자를 탈출 할 수

답변

3

...

$var = "<a href=\"JavaScript:newPopup('http://www.yourfantasyfootballreality.com/signin.php');\" class=\"two\">Sign In</a>"; 

또는, 즉 구분하는 작은 따옴표를 사용, 따옴표를 혼합 할 수 있습니다 문자열과 큰 따옴표를 사용하여 속성을 따옴표로 묶으십시오.

heredoc 또는 nowdoc을 사용할 수도 있습니다.

+0

감사를 얻을 :) – alex

1

"<a href='JavaScript:newPopup('http://www.yourfantasyfootballreality.com/signin.php');' class='two'>Sign In</a>"; 두 번째 'href 태그를 닫습니다. 당신은 그것을 탈출해야합니다, 그래서 당신은 같은 것을 할 것 :

$var = "<a href='JavaScript:newPopup(\"http://www.yourfantasyfootballreality.com/signin.php\");' class='two'>Sign In</a>"; 

그래서 실제로 출력 할 때 당신이 downvote을 제거하기위한 <a href='JavaScript:newPopup("http://www.yourfantasyfootballreality.com/signin.php");' class='two'>Sign In</a>