How to use PHP variable in Javascript?

前端 未结 5 1296
遇见更好的自我
遇见更好的自我 2021-01-22 23:18

I know you can\'t directly use PHP variables inside javascript code, but is there a way around it? I need to use these parameter\'s in javascript:

username: \'&l         


        
5条回答
  •  悲哀的现实
    2021-01-22 23:33

    You can assign that php value in any html object then you use the object value in js page

    for example

    PHP:

    $phpvalue = $_GET["sid"];
    

    HTML:

    
    

    JS:

    var phpval = document.getElementById('txtsamp').value;
    

提交回复
热议问题