나는이 똑같이 PHP 변수에 자바 스크립트 코드를 삽입 할 : 코드에PHP 변수의 자바 스크립트 코드?
Notice: Use of undefined constant w - assumed 'w' in /test.php on line 9
Notice: Use of undefined constant h - assumed 'h' in /test.php on line 9
Notice: Use of undefined constant w - assumed 'w' in /test.php on line 9
Notice: Use of undefined constant h - assumed 'h' in /test.php on line 9
Notice: Use of undefined constant id - assumed 'id' in /test.php on line 9
무슨 잘못 :
$ch = '<script> var w = window.innerWidth; var h = window.innerHeight; var id = "'. $row['ch_id'] .'" ; document.write(<iframe width="'+w+'" height="'+h+'" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="true" src="http://www.exemple/embed.php?width='+w+'&height='+h+'&channel='+id+'&autoplay=true"></iframe>); </script>';
내가 나에게이 오류를 줄? 사전에
덕분에
. 참고로'document.write' 사용을 중단해야합니다. –
또한 PHP는 concantenation 연산자로'.'를 사용합니다. – thatidiotguy
이 경우에는 OP가 스크립트 코드에서 JavaScript 형식을 유지하기를 원하기 때문에 여기서 '+'가 적절합니다. –